IPad UINavigationController横向问题

IPad UINavigationController横向问题,ipad,uinavigationcontroller,landscape,Ipad,Uinavigationcontroller,Landscape,我在以横向模式显示UINavigationViewController时遇到问题。视图将自动旋转到纵向模式。我已经花了大约3个小时来解决这个问题。如果我现在没有导航控制器,它可以正常工作。但是,我需要导航控制器,因为我必须从中推另一个viewcontroller 请提出任何解决问题的建议。这是密码 SharingViewController *sharingViewController = [[SharingViewController alloc] initWithNibName:@"Shar

我在以横向模式显示UINavigationViewController时遇到问题。视图将自动旋转到纵向模式。我已经花了大约3个小时来解决这个问题。如果我现在没有导航控制器,它可以正常工作。但是,我需要导航控制器,因为我必须从中推另一个viewcontroller

请提出任何解决问题的建议。这是密码

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];
如果您这样做:

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];

它应该会起作用。我也有同样的问题,但当我将modalPresentationStyle属性添加到viewController和UINavigationController时,它开始工作。

我会尝试一下。我所做的工作是手动更改导航控制器的框架。