我知道你必须使用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