我有經由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