View Controller Presentation Changes in iOS 13

Introduction

At the time of writing, WWDC 2019 is drawing to a close. Like many iOS developers I’m slowly processing all the new information that Apple threw at us and will be trying to watch as many videos as I can in the coming weeks (and months!)

  1. Do my apps work when built with Xcode 11 / iOS 13? Building with the latest tools opts app into new behaviour, bypassing backward-compatibility with previous iOS versions. Did anything break?
  2. What changes could/should I make to my apps to work better or take advantages of new iOS 13 features? This is the biggest task and will take the most time to investigate and implement. That’s a story for another day.

Default Modal Presentation Style Change

The default presentation is now page sheet, not full screen. The header documentation for modalPresentationStyle says:

Modal Presentations on iPhone

A form sheet, page sheet or popover presentation on iPhone is adapted to full screen unless a UIAdaptivePresentationControllerDelegatemethod is used to prevent the adaption. As an example, a Settings screen might be presented as a form sheet so that it appears full screen on iPhone and in the smaller form sheet size on iPad. Technically, the appearance/adaption depends on the horizontal size class. Form/page/popover presentations on Landscape iPhone Plus and XS Max devices don’t fill the screen because they are regular width. iPad appearance depends on slide over and split-screen multitasking size. It can change whilst a view controller is presented if the horizontal size class changes because the user adjusts or removes the split.

Adaptivity Settings Screen on iPhone XS: Xcode 10 build on iOS12, Xcode 10 build on iOS 13, and Xcode 11 build on iOS 13

View Controllers all the Way Down

If the presented view controller presents yet another view controller (and so on), the cards stack up with a nice animation. Note that only the top-most presented view controller and its presenting view controller can be seen (the presenting presenting view controller is no longer visible):

Modally-presented Settings screen presenting a modal INUIAddVoiceShortcutViewController on iOS 13

Size Changes

The new card-style appearance means that the presented view controller is not quite as tall on iOS 13 as it was on iOS 12:

Adaptivity presenting a form sheet on iPhone XS: Xcode 10 build on iOS12, and Xcode 11 build on iOS 13

I Want my Full Screen!

Explicitly asking for a full screen modal presentation will override this new behaviour. However, that might break your iPad behaviour (if you want a form or page sheet there). Please resist the temptation to check the device idiom and use a different presentation style for iPhone and iPad. If the last few years have taught us anything, it’s that we shouldn’t be making assumptions based on device types or screen sizes. If you want a form/page sheet appearance on iPad but full screen on iPhone you should be able to useUIAdaptivePresentationControllerDelegate to adapt to full screen in compact width environments (including the smaller iPad multitasking sizes).

Modal Presentations on iPad

Form Sheets

Form sheets presented on iPad are unchanged in iOS 13:

Adaptivity presenting a form sheet on 11" iPad Pro: Xcode 10 build on iOS12, and Xcode 11 build on iOS 13

Page Sheets

As noted above, the default modal presentation style on iOS 13 is now page sheet. On iPad the page sheet size has changed, in both portrait and landscape:

Adaptivity presenting a page sheet on 11" iPad Pro with default (Large) content size category: Xcode 10 build on iOS12, and Xcode 11 build on iOS 13
Adaptivity presenting a page sheet on 11" iPad Pro with default (Large) content size category: Xcode 10 build on iOS12, and Xcode 11 build on iOS 13
Adaptivity presenting a page sheet on 11" iPad Pro with ExtraExtraExtraLarge content size category: Xcode 10 build on iOS12, and Xcode 11 build on iOS 13
Adaptivity presenting a page sheet on 11" iPad Pro with ExtraExtraExtraLarge content size category: Xcode 10 build on iOS12, and Xcode 11 build on iOS 13

Other Presentations

Remember the header documentation for modalPresentationStyle:

Adaptivity default modal presentation of Split View Controller on 11" iPad running iOS 13

Swipe to Dismiss

Another important change that affects both iPhone and iPad is that non-full-screen modal presentations (except popovers) can be interactively dismissed with a downward swipe. The presenting view controller animates back up to full screen:

Interactive dismissal of modally-presented view controller on iPhone XS

Don’t Swipe me Bro!

This change is especially important for apps that push truly “modal” view controllers (either directly or onto the stack of a modally-presented navigation controller). If you are relying on the user tapping a Done button (or similar) or navigating back to the top of a navigation controller stack in order to dismiss a modally-presented view controller, the new swipe-to-dismiss behaviour might break your app because your dismiss button handler will not be executed.

Adding a Timer Profile to Pommie on iPhone X running iOS 13
  • set isModalInPresentation on the search controller itself so when it is presented when the user taps on the search bar, it will control whether interactive dismissal is possible.

Detecting Dismissal

As noted earlier, some apps might need to execute some code when a modally presented view controller is dismissed using a Cancel, Done or Save button (other than just dismissing it). For example, you might need to restart a timer in a game, or act upon some information that the user changed in the presented view controller. That code won’t be executed if the user dismisses with a swipe. Your button isn’t pressed, so its action handler won’t be called. This could break the behaviour of your app.

Resources

The WWDC 2019 videos will be the best place to discover what has changed in iOS 13, what changes you need to make to your apps to keep them working correctly when built on Xcode 11, and what changes you could make to improve them to take advantage of new features. Here’s a few to start with:

Conclusion

So far, I’ve not found any issues with my Xcode 10-built apps running on iOS 13. Apple’s backwards-compatibility really helps here. I was a little surprised to see the change in appearance of the grouped table view.

Adaptivity iOS App

The screenshots in this article were taken from the iOS simulator running my Adaptivity iOS app. Adaptivity is a tool for developers and designers to visualise the different screen sizes, layout margins, readable content guides, bar heights and Dynamic Type sizes that a modern, adaptive, iOS app uses when running on different devices and iPad multitasking sizes. The iOS 13 version of Adaptivity includes views for dark mode, browsing System Colors, browsing System Images (SF Symbols), and multiple scenes on iPad.

Other Articles That You Might Like

If you’re an iOS developer you might be interested in my long-running series of articles that show how apps adapt to newer device sizes depending on which Xcode version they are built with:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Geoff Hackworth

Independent and freelance software developer for iPhone, iPad and Mac