Min Soe
Min Soe

Reputation: 1254

IPad UINavigationController Landscape problem

I am having a problem in presenting UINavigationViewController 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];

Upvotes: 3

Views: 1111

Answers (1)

Josip B.
Josip B.

Reputation: 2464

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.

Upvotes: 1

Related Questions