我知道你必須使用IOS6的新旋轉方法,但似乎我寫的方法不起作用。IOS6旋轉問題
我設置好的我的plist文件,允許所有旋轉,但不portraitUpsideDown
然後我在我的的appDelegate如下:
self.navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
[self.window setRootViewController:navController]; //add nav controller to be the root view
然後在我的rootView,推到另一個控制器,我有:
WebViewViewController *webController = [[JBWebViewViewController alloc] init];
webController.urlString = urlName;
[self.navigationController pushViewController:webController animated:YES];
而在網絡控制器我哈哈五個:
#pragma mark - System Rotation Methods
//for any version before 6.0
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
//only allow landscape
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
/for 6.0+
- (BOOL)shouldAutorotate{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
我想要做的,是讓根視圖3度旋轉,但是當切換到Web視圖(注意我做俯臥撐的導航,而不是增加子視圖),我只想讓縱向視圖。
有人幫我請
------- UPDATE ----------
我創建的UINavigationController我自己navController子類中,我有一個BOOL landscapeModeOn那我可以設置要告訴自動旋轉功能
#pragma mark - System Rotation Methods
//for any version before 6.0
- (BOOL)shouldAutorotateToInterfaceOrientation (UIInterfaceOrientation)interfaceOrientation
{
if (landscapeModeOn) {
return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
} else {
return interfaceOrientation == UIInterfaceOrientationPortrait;
}
}
//for 6.0+
- (NSUInteger)supportedInterfaceOrientations{
if (landscapeModeOn) {
return UIInterfaceOrientationMaskAllButUpsideDown;
} else {
return UIInterfaceOrientationMaskPortrait;
}
}
- (BOOL)shouldAutorotate{
UIInterfaceOrientation ori = [UIDevice currentDevice].orientation;
if (landscapeModeOn) {
return ori != UIInterfaceOrientationPortraitUpsideDown;
} else {
return ori == UIInterfaceOrientationPortrait;
}
}
IN子視圖加載,我做的:
- (void)viewWillAppear:(BOOL)animated{
//get nav controller and turn off landscape mode
JBNavController *navController = (JBNavController*)self.navigationController;
[navController setLandscapeModeOn:NO];
[navController shouldAutorotate];
}
--------------------請參閱最佳答案的報價 對於IOS6,蘋果現在專注於將Storyboard的AutoLayout與新的旋轉定義一起使用,因此很難修復基礎上的iOS 4.3和iOS 5的編碼結構
從applefreak爲iOS6的一些微小的錯誤,他的建議暗示的:
你的情況的一個主要挑戰是不處理的方向。其實它的鎖定不同的視圖控制器,以特定的方向
雖然手動旋轉的觀點似乎真的很難,沒有任何錯誤的事,但現在看來,我想唯一的解決辦法,將發佈更多一旦解決
根據rooster117的答案通用的代碼,這是我的解決方案:http://stackoverflow.com/questions/12662240/how-to-make-app-fully-工薪正確地換自轉式-IOS-6/12662433#12662433] [1] [1]:http://stackoverflow.com/questions/12662240/how-to-make-app - 完全性工作,正確地換自轉功能於IOS-12662433分之6#12662433 – Carina