2014-10-17 58 views
-1

的情况是这样的:如何处理ios 8中每个视图控制器中的自动旋转?

可以说ViewControllers A,B。

一个只支持肖像模式。 B支持所有模式。

我点击A的缩略图图像并在B中显示完整的图像。因此,自动旋转在B中正常工作。它工作正常,如果我在B处于肖像模式时从B回到A。

但问题是,如果我在B模式下保持手机处于横向模式,那么如果我回到A那么它也会显示不应该发生的横向。

我工作完全正常的iOS7,但它是搞乱在iOS的8

任何人都可以在这方面帮助?提前致谢。

+0

看一次大小班..! – Avis 2014-10-17 23:28:33

+0

@ Avis444是的,我看着他们。但我不明白如何实施它们。你能给我一个例子来实现它们吗? – 2014-10-17 23:39:04

回答

0

你的代码有问题。我刚刚实施它来测试,它工作正常。

我addded至A:

到B
- (NSUInteger) supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

补充:

- (NSUInteger) supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAll; 
} 

,并添加按钮将打开B:

- (IBAction) buttonAction:(id)sender 
{ 
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"itShouldWork" bundle:nil]; 
    MyViewController *controller = (MyViewController *)[story instantiateInitialViewController]; 
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller]; 
    [self presentViewController:nav animated:YES completion:nil]; 
} 

正如我所说的,它的工作原理精细。在iPhone 5设备(iOS 8)上测试。内置在Xcode 6

0

这似乎是一个错误在iOS的8

正如你可以用在你的UINavigationController B控制一种解决方法。随着检查的iOS版本,它看起来像

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8")) { 
    [self presentViewController:[[UINavigationController alloc] initWithRootViewController:controllerB] animated:YES completion:nil]; 
} else { 
    [self presentViewController:controllerB animated:YES completion:nil]; 
} 

宏检查IOS版本可以发现here

相关问题