[英]Crash on shouldAutorotate() method when UIAlertview show in Landscape viewcontroller?
我正在開發一個僅使用一個方向(即人像)的應用程序。 這是設備方向設置:
但是在我的應用程序中,我只想在“橫向右”模式下顯示視頻播放器( MPMoviePlayerViewController
自定義播放器),並且不應旋轉它。 一切正常,我的意思是該自定義播放器在“橫向右移”中完美顯示,但是當我使用UIAlertview
應用程序在此方法上崩潰了:
- (BOOL)shouldAutorotate {
return NO;
}
這些是其他一些定向方法:
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeRight; // or Right of course
}
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
- (NSUInteger)supportedInterfaceOrientations
#else
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
#endif
{
return UIInterfaceOrientationMaskLandscape;
}
我收到此錯誤:
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [UIAlertController shouldAutorotate] is returning YES'
iOS8:UIAlertController
#import "UIAlertController+Portrait.h"
@implementation UIAlertController (Portrait)
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
@end
iHTCboy的答案在轉換為swift后為我解決了。
快速4:
extension UIAlertController {
override open var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .all }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.