簡體   English   中英

應用程序輪換在iOS7中有效,但在iOS8中無效

[英]App rotation works in iOS7 but not iOS8

我在讓我的應用在iOS8中在縱向和橫向之間旋轉時遇到問題。 在iOS7中工作正常。 在我的主視圖控制器中,我有以下內容。

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
    return YES;     // for iOS7 compatibility
}

- (BOOL)shouldAutorotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return  UIInterfaceOrientationMaskAll;
}

我可以確認(通過調試)在iOS8下啟動時調用了后兩者,但在屏幕旋轉時沒有調用。

我正在使用自動布局,並且IB中的錯誤和警告為零。 (啟動時在調試器中也沒有)。

Info.plist文件具有“ UISupportedInterfaceOrientations”和“ UISupportedInterfaceOrientations〜ipad”的所有4個方向。

這有點不尋常,因為在模擬器(8.1)中,無論方向如何,應用始終以縱向模式啟動。 但是,在設備(8.0)上,應用始終以當前方向啟動。 但是,兩者都不允許應用內旋轉。

我搜尋了互聯網和Apple的文檔。 朝正確方向的任何想法或指示將不勝感激。

1)首先單擊您的項目。
2)然后單擊常規選項卡。在部署信息下,您將找到設備方向。
3)檢查所有四個選項。

可能會對您有幫助。 如果它不起作用,請通知我。
謝謝

在您的appdelegate中使用它。

 -(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    return UIInterfaceOrientationMaskAll;
else  /* iphone */
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

我終於發現了問題。 我一直在從應用程序委托的“初始化”方法中調用“ beginGeneratingDeviceOrientationNotifications”:

+ (void)initialize {
    // ...
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}

自iOS初期以來,此方法就一直很好,並且該調用似乎並未被棄用,但由於某種原因,它在iOS8中不再起作用-至少在此早期階段不起作用。 輕松解決。 感謝所有考慮此問題的人。

暫無
暫無

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

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