IPad UINavigationController风景问题

问题描述:

我在呈现UINavigationViewController风景模式时出现问题。该视图会自动旋转至纵向模式。我已经花了大约3个小时解决这个问题。如果我没有导航控制器的话,它工作的很好。但是,我需要导航控制器,因为我必须从其中推出另一个视图控制器。IPad UINavigationController风景问题

请提出任何问题以解决问题。这是代码。

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它开始工作。

+0

我会试试看。我所做的工作是我手动更改了导航控制器的框架。 –