2012-11-21 81 views
1

方向在presentViewController中不起作用。即使我正在使用UINavigationController類別。 supportedInterfaceOrientations方法被調用,但沒有更改。在基本viewcontroller中,shouldAutorotate方法返回YES。我有以下代碼。ios 6 presentViewController

我正在使用此代碼。

ViewControllerOne *viewOne = [[ViewControllerOne alloc]init]; 

UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:viewOne]; 
navCtrl.modalPresentationStyle = UIModalPresentationFormSheet; 

[self presentViewController:navCtrl animated:YES completion:nil]; 

請幫幫我。在此先感謝...

+0

[presentViewController不支持iOS 6中的方向]的可能重複(http://stackoverflow.com/questions/12566780/presentviewcontroller-not-supporting-orientation-in-ios-6) –

回答

1

您使用哪個模擬器ios 5或ios 6? 發佈一些更多的代碼。 另請參閱的appDelegate此link.

代替這行代碼:

[window addSubview:viewController.view]; 

由這一行:

[window setRootViewController:viewController]; 

檢查這兩個iOS 5及6

if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) 
     { 
      [self presentViewController:navigationControllerCustom animated:YES completion:nil]; 
     } 
     else 
     { 
      [self presentModalViewController:navigationControllerCustom animated:YES]; 
     } 

嘗試使用輪換

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{ 
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown); 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; 
} 
相關問題