簡體   English   中英

iOS:通用應用程序不會旋轉,永遠不會調用willRotateToInterfaceOrientation

[英]iOS: Universal app won't rotate, never calls willRotateToInterfaceOrientation

我的(通用iPhone / iPad)應用程序不會旋轉。 在我所有的視圖控制器中,我都對方法shouldRotate返回“ YES”,但是我的視圖控制器的willRotateToInterfaceOrientation方法從未得到調用。

這是常見問題嗎?

在該通用應用程序中,您是否使用splitViewController? 如果是這樣,請確保所有viewControllers返回Yes都應為autoRotate。

我將一個viewControllers(實際上是NavigationViewControllers)數組傳遞給splitViewController,而我的視圖沒有旋轉。 這是因為我的左手viewController沒有實現shouldAutorotate。 我認為這是因為使用splitViewController時,iPad上的旋轉不同於iPhone上的旋轉。 旋轉時顯示兩個viewControllers。 我猜兩者都必須支持橫向模式?

如果您不希望一個viewController的旋轉旋轉,請執行條件檢查,以查看shouldAutoRotate方法是否在iPad上。

您是否在使用標簽欄? 您將需要對Tabbar控制器進行子類化,並在旋轉時返回yes。

我剛遇到這個。 解決方案是將UISplitViewController子類化並添加

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

即使各個視圖控制器已經返回YES,也要等到我添加拆分視圖控制器子類后,它才起作用。

暫無
暫無

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

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