我最近更新了我的iPad到iOS5,發現了一個相當奇怪的問題。我的應用程序中有兩種不同的佈局。我通過參考self.interfaceOrientation
更新didRotateFromInterfaceOrientation
方法中的視圖。但現在self.interfaceOrientation
沒有得到更新,並且視圖顯示出奇怪。任何人都可以在這個問題上拋出一些光。有什麼新的iOS 5給我這個麻煩?「self.interfaceOrientation」未在iOS 5中更新
0
A
回答
0
我不知道iOS 5有什麼變化,但是這裏是我自iOS 4以來使用的代碼,並且從此開始工作得很好。
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
switch (toInterfaceOrientation){
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationPortraitUpsideDown:
//change layout to Portrait
return YES;
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
//change layout to Landscape
return YES;
default:
return NO;
}
}
0
您可以使用
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
,並設置定向變量,但它不是一個很好的解決方案。
0
我認爲這裏的問題是你實際上抓住設備方向的方式。以我的經驗self.interfaceOrientation
並不總是可靠的。
有幾種方法來獲取當前UIInterfaceOrientation
,但是從我的理解,從狀態欄獲得的方位是唯一比較有效的方法使用代替嘗試:
[UIApplication sharedApplication].statusBarOrientation
提醒 - UIInterfaceOrientation
和UIDeviceOrientation
是不一樣的!它們也可能會在不同的時間更新,具體取決於您如何初始化它們。
你也可以在類似的問題上檢查this answer。
相關問題
- 1. AVAudioPlayer未在IOS 5
- 2. IOS 5 SDK更新問題
- 3. UITableView未更新iOS
- 4. iOS KeychainItemWrapper未更新
- 5. 更新iOS 5中的進度條
- 6. MVC 5更新行中的未知列
- 7. iOS,orientationchanges,在iOS 5中觸發,但在iOS中未觸發6
- 8. iOS CBPeripheral Services未更新
- 9. 無法更新sqlite3表iOS 5
- 10. iOS leaderBoard得分未更新問題ios?
- 11. 在iOS 5中重置UIWebView,iOS 5
- 12. 在iOS 5中更改了scrollviewTexturedBackgroundColor嗎?
- 13. iOS 5上未繪製的圖表5
- 14. ExtJS 5工具欄中的標籤在溢出時未更新
- 15. iOS 5中的新錯誤:WebKit丟棄未捕獲的異常
- 16. iOS - deviceready在5秒後未觸發
- 17. iOS 4和5兼容性:提示用戶更新iOS
- 18. CollectionViewCell子圖層在iOS 10之前未更新iOS 10
- 19. Tableview無法在數據更改後重新載入:IOS 5
- 20. iOS應用程序圖標未更新
- 21. iOS PubNub SDK更新PNChannelProtocol.h未找到
- 22. 如何在laravel 5中更新數組?
- 23. laravel 5在一行中更新多列?
- 24. 更新iOS中10
- 25. ICollectionView在UI中未更新
- 26. SharedPreferences在onResume中未更新()
- 27. FACT_ACTIVITIES未在Worklight中更新
- 28. CSS在WordPress中未更新
- 29. 在iOS 5中使用UIImagePickerController但在ios 4.x中未使用內存警告
- 30. 在XCode 5中使用iOS 5 Simulator?
這並沒有回答這個問題 –
我提供了一種替代方法來實現他的佈局,當方向改變時。這種替代方式解決了問題中描述的錯誤。 – Louis
啊,我明白了;您建議將佈局更改插入您的評論。我誤解了。儘管如此,這仍然是一個糟糕的主意。 ''''''''''''''''''''''''''''''''''''如果將控制器放在導航控制器中,它將快速連續調用該方法4次並緩存返回值。 –