UIAlertController:supportedInterfaceOrientations was invoked recursively

来源:互联网 发布:海尔cosmo平台 知乎 编辑:程序博客网 时间:2024/06/10 21:19

在使用UIAlertController *sheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:(UIAlertControllerStyleActionSheet)];时候,

或者使用UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"从相册中选取",@"拍照", nil];

时候,会有奔溃:

UIAlertController:supportedInterfaceOrientations was invoked recursively!

然后我给的解决方案是:

建分类,添加分类方法,避免递归调用。

#import <UIKit/UIKit.h>
@interface UIAlertController (supportedInterfaceOrientations)
@end




#import "UIAlertController+supportedInterfaceOrientations.h"

@implementation UIAlertController (supportedInterfaceOrientations)
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000
- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}
#else
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}
#endif

@end

0 0
原创粉丝点击