Supported orientations has no common orientation with the application, and [UIAlertController shouldAutorotate] is returning YES
解决方法
//
#import "UIAlertController+FixCrash.h"
@implementation UIAlertController (FixCrash)
+ (void)load
{
Class vc = NSClassFromString(@"UIAlertController");
SEL originalSelector = @selector(shouldAutorotate);
SEL swizzledSelector = @selector(fixCrashReturn);
Method originalMethod = class_getInstanceMethod(vc, originalSelector);
Method swizzledMethod = class_getInstanceMethod([self class], swizzledSelector);
BOOL didAddMethod = class_addMethod(vc,originalSelector,method_getImplementation(swizzledMethod),method_getTypeEncoding(swizzledMethod));
if(didAddMethod) {
class_replaceMethod([self class],swizzledSelector,method_getImplementation(originalMethod),method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
}
- (BOOL)fixCrashReturn{
return NO;
}
@end