2010-08-26 112 views
0

我在基於ipad應用程序的分割視圖中使用了多個uiviewcontrollers。 有Web服務。對於某些特定的Web服務(例如註銷),我需要刪除拆分 視圖並插入新視圖即登錄屏幕。但大部分時間都應該LoginRootate方法的Login視圖不會被調用導致愚蠢的應用程序不旋轉。 背後的原因是什麼?我該怎麼辦?shouldAutoRotate方法無法正常工作..?

回答

0

確保你沒有提取您的UIViewController一個UIView其中shouldAutorotateToInterfaceOrientation:函數返回YES,然後添加的UIView到另一個UIView的使用addSubView。我以前遇到過。

+0

其實我通過下面的鏈接,我發現我在窗口中添加2個視圖做錯誤。即loginview和splitview。現在我已經將loginview作爲模態視圖解決了我的問題。現在我的應用旋轉得很好。 Thakns。 – Mahesh 2010-08-26 13:21:32

0

確保您所有的視圖控制器爲您的iPad構建返回YESshouldAutorotateToInterfaceOrientation: - 至少那些在那個時候是可見的。

參見:iPad orientation change issue

+0

好的,謝謝它幫助我,我會嘗試。 其實在shouldAutorotateToInterfaceOrientation:方法我已經計算viewcontrollers的大小,但在給出不好的尺寸,即它提供prev方向大小,而不是當前。所以我根據尺寸做了一些手動調整。它可能會影響嗎? – Mahesh 2010-08-26 08:37:32

1

維護我的遺留代碼我加了這個。

- (BOOL)shouldAutorotate{ 
    UIDeviceOrientation orientation = [UIDevice currentDevice].orientation; 
    if (orientation == UIDeviceOrientationUnknown) return YES; 
    BOOL result = [self shouldAutorotateToInterfaceOrientation:orientation]; 
    return result; 
} 

然後原始代碼返回有效的自動旋轉信息。