Testing my app in Xcode 11 (beta) for iOS-13 (beta) updates and I'm getting crash on when I tried to instantiate viewController from storyboard.
In previous versions its working fine with the following code:
XYZController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER"];
Now for iOS 13 Apple introduces new method i.e.
XYZController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"IDENTIFIER" creator:^__Kindof UIViewController *__Nullable(NSCoder *_Nonnull coder){
return [XYZController alloc] initWithCoder:coder];
}];
Executing both method in iOS-13 cause crash. While crash shows somewhere else.
Here is my crash report.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '' returned nil from -traitCollection, which is not allowed.
Note: Temporary Solution
I also have face this issue and there are two temporary fixes I have found. First is to create object/property of the controller that need to be instantiate and instantiateViewControllerWithIdentifier
in your controllers's viewDidLoad
. App will not crash.
Second is to instantiate controller in dispatch_async(dispatch_get_main_queue())
. These both tricks worked for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With