Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ios 8中处理每个视图控制器中的自动旋转?_Ios_Ios8_Autorotate - Fatal编程技术网

如何在ios 8中处理每个视图控制器中的自动旋转?

如何在ios 8中处理每个视图控制器中的自动旋转?,ios,ios8,autorotate,Ios,Ios8,Autorotate,场景如下: 比如说,视图控制器A,B A仅支持纵向模式。B支持所有模式 我点击A中的缩略图图像,在B中显示完整图像。因此,自动旋转在B中工作正常。如果在B处于纵向模式时,我从B返回A,它工作正常 但问题是,如果我在B时将手机保持在横向模式,那么如果我回到A时,手机也会显示不应该出现的横向模式 我在iOS7中工作得很好,但在iOS8中却搞砸了 有人能帮忙吗?提前感谢。您的代码有问题。我只是为了测试而实现了它,它工作得很好 我补充说: - (NSUInteger) supportedInterfac

场景如下:

比如说,视图控制器A,B

A仅支持纵向模式。B支持所有模式

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

但问题是,如果我在B时将手机保持在横向模式,那么如果我回到A时,手机也会显示不应该出现的横向模式

我在iOS7中工作得很好,但在iOS8中却搞砸了


有人能帮忙吗?提前感谢。

您的代码有问题。我只是为了测试而实现了它,它工作得很好

我补充说:

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

- (NSUInteger) supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}
并将按钮添加到A以打开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构建,这似乎是iOS 8中的一个bug

作为一种解决方法,您可以将B控制器包装在UINavigationController中。除了检查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版本的宏。

查看大小类一次@是的,我看着他们。但我不太明白如何实施它们。你能给我一个例子来实现它们吗?