开发者

Push a view controller in portrait from a view controller that's in landscape

开发者 https://www.devze.com 2023-03-09 07:31 出处:网络
I have a UITableViewController that works in both portrait and landscape. From this controller I push another view controller on to the navigation controller. This new viewController is portrait only.

I have a UITableViewController that works in both portrait and landscape. From this controller I push another view controller on to the navigation controller. This new viewController is portrait only.

The problem is that when I am in landscape and push the view controller the new viewcontroller is in landscape as well until I rotate it to portrait. Then it's stuck in portrait as it should be.

Is it possible to always make it appear in portrait? Even if its parent is pushing it in landscape?

Update:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInter开发者_运维知识库faceOrientationPortrait);
}


In viewWillAppear: after statusbar orientation change put this:

//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];

Hopefully it will help!

P.S.Tested on sdk 3.2.5 ios 5.0.1.


In your viewWillAppear: use the following code:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号