在使用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