UIViewController: modalPresentationStyle ignored if set after accessing the presentationController property

Originator:drb100
Number:rdar://FB7601109 Date Originated:26/02/20
Status:Open Resolved:
Product:UIKit Product Version:Xcode 11.3.1
Classification: Reproducible:Yes
 
If you access the presentationController property before setting the modalPresentationStyle, the style is ignored.

This code will result in a full screen modal presentation, as expected:
   let viewController = UIViewController()
   viewController.modalPresentationStyle = .fullScreen
   _ = viewController.presentationController
   present(viewController, animated: true)

This code will result in a page sheet modal presentation, which is not expected:
   let viewController = UIViewController()
   _ = viewController.presentationController
   viewController.modalPresentationStyle = .fullScreen
   present(viewController, animated: true)

I would expect to be able to access the presentationController property at any point and it not to affect the modalPresentationStyle value. This resulted in a day of dev time lost to trying to figure out why the modal style was not being applied!

I have attached a minimal project to display this behaviour. This was observed on Xcode 11.3.1, with iOS 13.3 simulator.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!