[英]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.