我正在开发一个应用程序,其中我只使用一个方向,即Portrait。这是设备方向设置:
但在我的应用程序中有视频播放器(MPMoviePlayerViewController
的自定义播放器),我想仅在Landscape Right模式下显示它,它不应该旋转。
这工作正常,我的意思是这个自定义播放器完全在Landscape Right中显示,但当我使用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'
答案 0 :(得分:0)
iOS8:UIAlertController
#import "UIAlertController+Portrait.h"
@implementation UIAlertController (Portrait)
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
@end
答案 1 :(得分:0)
在swift 4中:
extension UIAlertController {
override open var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .all }
}
答案 2 :(得分:-1)