Archive for the ‘Swift’ Category

Opening View in iOS 13

Wednesday, April 7th, 2021

I had a legacy iPad project that began having issues with views opening in a ‘modal’ window instead of full screen. Technically, they were being instantiated as modals, but since IOS 13 the modal view is what will be presented when using instantiateViewControllerWithIdentifier. It’s a simple fix:

if (@available(iOS 13, *)) {
    nextPage.modalPresentationStyle = UIModalPresentationCustom;
}

Unfortunately when you dismiss the view you instantiate using this, it’s parent view no longer receives a viewDidAppear event. So I had to add a call to viewDidAppear before running dismissViewControllerAnimated like so:

if (@available(iOS 13, *)) {
    [self.presentingViewController viewDidAppear:false];
}