我工作在通用應用程序,它工作正常,直到ios 5,但在ios 6中存在定位問題。我的應用程序只處於肖像模式。問題是當我的ipad處於橫向模式時,並且比開始我的應用程序的方向更改爲protrait時。所以請幫助我一些代碼,以便我強制我的應用只能在應用啓動之前獨立於設備的方向而處於專業模式定位問題在ios 6
0
A
回答
2
發生這種情況是因爲Apple已經改變了管理UIViewController方向的方式。在Ios6中,Oreintation處理方式不同。在iOS6容器(例如UINavigationController)中,不要諮詢子項以確定它們是否應該自動旋轉。默認情況下,應用程序和視圖控制器支持的界面方向設置爲UI成語的UIInterfaceOrientationMaskAll和iPhone成語的UIInterfaceOrientationMaskAllButUpsideDown。因此默認情況下,設備獲取方向已更改。
所以需要執行一些步驟。
1 - 設置所述取向從這裏
2 -place本規範中FirstViewController加入到RootViewController的
@implementation UINavigationController (RotationIn_IOS6)
//Here UINavigationController is the RootViewController added To the Window
-(BOOL)shouldAutorotate
{
return [[self.viewControllers lastObject] shouldAutorotate];
}
-(NSUInteger)supportedInterfaceOrientations
{
return [[self.viewControllers lastObject] supportedInterfaceOrientations];
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return [[self.viewControllers lastObject] preferredInterfaceOrientationForPresentation];
}
@end
**將下面的方法中的ViewController,在IOS6中引入允許修改**
- (BOOL)shouldAutorotate
{
return NO;
}
/*Return the Number of Oreintation going to supported in device*/
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
// Returns interface orientation masks.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return (UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown ) ;
}
0
在您的ViewController.m
中,您必須定義支持的方向。在IOS 6中,這是處理支持的方向的方法。
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
UIInterfaceOrientationMaskAll
意味着它將支持所有view
方向。
而且閱讀蘋果文檔 - Doc about Orientation
4
首先,我們必須設定在Targets->要點支撐取向...
在iOS6.0 shouldAutorotateToInterfaceOrientation方法是deprecated.So,採用這個方法,我們必須使用shouldAutorotate方法..
並與方法supportedInterfaceOrientations我們要設置我們要像UIInterfaceOrientationMaskAll其方位,如果我們希望所有的方位
相關問題
- 1. ios中的cocos2d定位問題<= 6
- 2. iOS 6自動佈局定位問題
- 3. iOS-6 UI問題和定位支持
- 4. iOS定位問題
- 5. 定位問題iOS 5
- 6. 問題在iOS 6中
- 7. CollectionView Ios 6問題
- 8. iOS 6 AVAudioSession問題
- 9. iOS 6 inApp問題
- 10. iOS 6上的YouTube播放器定位問題
- 11. iOS視圖定位問題
- 12. UITabBarController的定位問題iOS
- 13. iOS 6的定位與NavigationController
- 14. ios 6定位方法
- 15. IE 6 css問題與絕對定位
- 16. 與iOS JSON問題6
- 17. iOS 6方向問題
- 18. iOS 6:UIAlertView旋轉問題
- 19. PayPal問題與iOS 6
- 20. iOS 6 MSTag common_button_done問題
- 21. IOS 6 MPMoviePlayerController旋轉問題
- 22. 問題與iOS 6自轉
- 23. 定位問題在IOS 5.1中?
- 24. 如何定位iOS 5和iOS 6
- 25. ios 6和ios 7 Gui問題
- 26. iOS 5中的iPad定位問題
- 27. CSS問題的位置:在橫向模式下固定的iOS 9 iPhone 6+
- 28. 在iOS 7中的iOS 7按鈕可定位性問題
- 29. Exif iOS中的定位問題
- 30. ios 11 UITabBar UITabBarItem定位問題
你能請將didFinishLaunchingWithOptions方法的代碼放在Appdelegate類 –
中您爲IOS 6方向寫了什麼? – TheTiger
http://stackoverflow.com/a/12651309/1059705 – Bala