Hi,
One application I'm maintaining crashes on iOS16 beta 3 with an exception "Supported orientations has no common orientation with the application, and [UIAlertController shouldAutorotate] is returning YES". I'm running out of ideas how totrace down the reason.
- It only happens when the Main Thread checker is enabled
- it happens even if I display the alertcontroller totally early in applicationDidFinishLaunching
- a new setup sample with pretty much identical code (see below) until applicationDidFinishLaunching (and main.xib) does not throw the exception regardless of the Main Thread checker state
- I validated the build settings are identical between the sample and the crashing app
#import "OCViewController.h"
@interface OCAppDelegate: NSObject <UIApplicationDelegate>
@property (nonatomic, readwrite, strong) IBOutlet UIWindow *window;
@property (nonatomic, readwrite, strong) IBOutlet UINavigationController *navigationController;
@end
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([OCAppDelegate class]));
}
}
@implementation OCAppDelegate
- (void)applicationDidFinishLaunching:(UIApplication *)application {
OCViewController *vc = [OCViewController new];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
[vc showAlert];
}
@end
@implementation OCViewController
- (IBAction) showAlert {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"title" message:@"Test" preferredStyle:UIAlertControllerStyleAlert];
// NSLog( @"%@", [[[[UIApplication sharedApplication] keyWindow] rootViewController] valueForKey:@"_printHierarchy"] );
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {}
]
];
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentViewController:alertController animated:YES completion:nil];
}
@end
The backtrace is
+[NSException raise:format:] + 112
-[UIViewController __supportedInterfaceOrientations] + 808
-[UIViewController __withSupportedInterfaceOrientation:apply:] + 48
-[UIViewController setInterfaceOrientation:] + 108
-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 268
-[UIView(Internal) _didMoveFromWindow:toWindow:] + 1232
-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 112
-[NSISEngine withBehaviors:performModifications:] + 84
-[UIView _postMovedFromSuperview:] + 672
-[UIView(Internal) _addSubview:positioned:relativeTo:] + 1904
-[_UIAlertControllerPresentationController presentationTransitionWillBegin] + 148
__80-[UIPresentationController _initViewHierarchyForPresentationSuperview:inWindow:]_block_invoke + 2008
[....]