2013-04-28 25 views
0

我知道:默認情況下,應用程序和視圖控制器的支持的接口方向設置爲UI成語的UIInterfaceOrientationMaskAll和iPhone成語的UIInterfaceOrientationMaskAllButUpsideDown。所以,當我使用Single View Application模板創建一個新項目時,爲了在iPhone中執行所有方向,我在ViewController.m中添加了兩個方法。它的工作!我如何處理iPhone iOS6中的UINavigationController的UIInterfaceOrientationPortraitUpsideDown

- (NSUInteger)supportedInterfaceOrientations{ 

    return UIInterfaceOrientationMaskAll; 
} 
- (BOOL)shouldAutorotate 
{ 
    return YES; 
} 

然後我改變了一些碼方法下面AppDelegate.m到應用程序的根視圖從UIViewController中改變的UINavigationController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    // Override point for customization after application launch. 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
     self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil]; 
    } else { 
     self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil]; 
    } 
    if(myNavigationController == nil) 
     myNavigationController = [[UINavigationController alloc]initWithRootViewController:self.viewController]; 

    self.window.rootViewController = self.myNavigationController; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 

在此之後,我不能處理在iPhone iOS6的所述UIInterfaceOrientationPortraitUpsideDown模擬器。我該如何解決這個問題?我試圖在舊主題中搜索一些代碼,但它仍然不起作用。

+0

[ios 6中的方向問題]的可能重複(http://stackoverflow.com/questions/13023936/orientation-issue-in-ios-6) – Vishal 2013-04-28 02:01:19

回答

0

myNavigationController屬性?您將其引用爲myNavigationControllerself.myNAvigationController。似乎不一致,尤其是在您初始化引用ivar的對象之後,然後使用該屬性設置窗口的rootViewController。

此外,你應該澄清你的問題。我想你是問如何讓iPhone自動旋轉到顛倒的肖像。答案是:不。 iPhone不支持水平旋轉鎖定(不像iPad),並且違背設計準則。

這就是說:你可能想要檢查你的所有viewControllers實現旋轉委託,並且他們都支持iPhone上下顛倒旋轉。我知道你說過你開始使用單視圖應用程序模板,但是應該沒有其他原因阻止旋轉。

編輯:你應該檢查的另一件事是你的目標設置。這裏的「支持的界面方向」部分可能會覆蓋您的自定義旋轉代碼。

相關問題