2013-02-27 59 views
1

我有一個應用程序,支持所有四個方向,在iOS 5上工作正常。iOS 6旋轉到人像顛倒不適用於UITableViewController,iOS 5很好

然而,的iOS 6,我所有的的UIViewController類運轉正常,但我的UITableViewController類不旋轉PortraitUpsideDown

支持的應用程序的方向包括所有四個選項。

的AppDelegate中支持所有方向:

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

我所有的視圖類的實現必要的方法,包括推出針對iOS 6:

- (NSUInteger)supportedInterfaceOrientations 
{ 
    //return (UIInterfaceOrientationMaskAll); 
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown); 
} 

- (BOOL)shouldAutorotate 
{ 
    BOOL bReturn = [self shouldAutorotateToInterfaceOrientation:self.interfaceOrientation]; 
    return (bReturn); 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (YES); 
} 

我能找到的唯一區別就是這樣顯示視圖。

的UIViewController

InfoViewController *infoController = [[InfoViewController alloc] initWithNibName:@"InfoViewController" bundle:[NSBundle mainBundle]]; 
[self presentModalViewController:infoController animated:YES]; 

的UITableViewController

MenuViewController *menuController = [[MenuViewController alloc] initWithNibName:@"MenuViewController" bundle:[NSBundle mainBundle]]; 
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:menuController]; 
[self presentModalViewController:navigationController animated:YES]; 

不能完全確定什麼影響執行會對旋轉,甚至比這更確定的該怎麼辦纔好。

任何指導將不勝感激。

+0

嗯,剛剛發生,我提出了一個UINavigationController,而不是我的MenuViewController對象。不確定這是否是實際問題,或者如何將支持的方向與UINavigationController對象相關聯。 – GRW 2013-02-27 02:38:36

回答

5

根據我上面提出的評論,我創建了一個新類,它繼承自UINavigationController並添加了識別支持的方向的方法。

- (NSUInteger)supportedInterfaceOrientations 
{ 
    //return (UIInterfaceOrientationMaskAll); 
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown); 
} 

然後,當我需要presentModalViewController的UITableViewController,創建我的新RotationNavigationController類的對象。

似乎已經解決了我所有的問題。

+0

這是一個省時的答案。它確實有效。我有這個問題好幾天了。非常感謝您與我們分享您的答案。 – SparkyNZ 2013-10-23 01:23:56

0
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { 
      if UIDevice.currentDevice().userInterfaceIdiom == .Phone { 
       return UIInterfaceOrientationMask(rawValue: UIInterfaceOrientationMask.Portrait.rawValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue) 
      } else { 
       return .All 
      } 
    } 
+0

這對我有用,使用Swift – user3761851 2016-05-17 15:46:09

相關問題