我有经由plist文件配置成支持肖像的应用程序,景观左和右横向取向(即UISupportedInterfaceOrientations设置为UIInterfaceOrientationPortrait,UIInterfaceOrientationLandscapeLeft,和UIInterfaceOrientationLandscapeRight)。但是我已经将支持的方向限制在视图控制器内部。如果我在视图控制器的视图上显示UIActionSheet,然后旋转设备,UIActionSheet旋转到新的方向。这只发生在运行iOS 8(GM种子)的设备上。iOS 8的UIActionSheet忽略视图控制器supportedInterfaceOrientations和shouldAutorotate
我想UIActionSheet遵循包含视图控制器的规则,而不是旋转。思考?
我不希望这样的事情发生: screenshot http://oi58.tinypic.com/20tgto2.jpg
UIViewController的示例代码:
- (IBAction)onTouch:(id)sender
{
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:@"hi"
delegate:nil
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"Open", nil];
[actionSheet showInView:self.view];
}
#pragma mark - Rotation methods
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
当然,有一种新的“首选”方式,但为什么只是因为引入了一种新方法而改变/破坏旧的工作功能呢?这种新方式是获得原始行为的唯一方法吗? – Bushrod 2014-09-18 19:04:59
不,因为iOS7用户仍然需要处理旧的警报/工作表。显然是一个需要修复的错误。 – Morrowless 2014-09-25 04:27:29
在iOS7上,旧的UIActionSheet不会出现旋转问题。在iOS7及更旧版本上使用UIActionSheet。在iOS8和更新版本上使用UIAlertController。检查NSClassFromString(@“UIAlertController”)以确定使用哪个代码。 – Awesomeness 2014-10-05 14:13:12