簡體   English   中英

模擬器中的iOS 6自動旋轉與實際的iOS 6設備不同

[英]iOS 6 autorotation in simulator varies from actual iOS 6 device

我的應用程序不會在iOS 6 GM模擬器中自動旋轉,但它在設備上使用相同版本的iOS。 這可能是一個模擬器錯誤嗎? 該應用程序正在使用已棄用的自動旋轉方法,但它們在設備本身上工作正常,這讓我想知道模擬器API是否不同?

它應該仍然適用於已棄用的旋轉方法,但您需要將以下內容添加到didFinishLaunchingWithOptions:方法:

self.window.rootViewController = yourRootViewController;

這告訴主window將旋轉通知發送到哪個視圖控制器。 這是iOS 6.0 SDK的新功能。

這是我為了讓我的應用再次運行而添加的內容:

// Tell the system what we support
- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
    return YES;
}

// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

添加以下內容還不足以使其在模擬器上運行:

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (BOOL) shouldAutorotate {
    return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}

為了使它工作,我還在appDelegate類的didFinishLaunchingWithOptions函數中添加了以下內容:

self.window.rootViewController = viewController;

這次添加后我停止了以下錯誤: 應用程序窗口應該在應用程序啟動結束時有一個根視圖控制器

- (BOOL)shouldAutorotate {
    return NO;
}

並將app plist文件中根視圖控制器支持的旋轉設置為僅縱向。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM