I am having a problem in presenting UINavigationVie开发者_运维技巧wController in landscape mode. The view is automatically rotated to portrait mode. I already spent around 3 hours solving on this issues. It is working fine if I present without navigation controller. But, I need navigation controller because I have to push another viewcontroller from that.
Please suggest anything to fix the issue. Here's the code.
SharingViewController *sharingViewController = [[SharingViewController alloc] initWithNibName:@"SharingViewController" bundle:nil];
UINavigationController *navi = [[[UINavigationController alloc] initWithRootViewController:sharingViewController] autorelease];
[navi setWantsFullScreenLayout:YES];
[navi.view setAutoresizesSubviews:NO];
[navi.navigationBar setHidden:YES];
navi.view.autoresizingMask = UIViewAutoresizingFlexibleWidth;
navi.visibleViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth;
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:navi animated:YES];
If you do this:
SharingViewController *sharingViewController = [[SharingViewController alloc] initWithNibName:@"SharingViewController" bundle:nil];
sharingViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
UINavigationController *navi = [[[UINavigationController alloc] initWithRootViewController:sharingViewController] autorelease];
navi.modalPresentationStyle = UIModalPresentationCurrentContext;
...
[[self navigationController] presentModalViewController:navi animated:YES];
it should work. I had same problem, but when I added modalPresentationStyle property to viewController and to UINavigationController it started working.
精彩评论