iOS 10 - Status bar style ignored when modally presenting view controller with UIModalPresentationCustom and custom UIPresentationController
| Originator: | liam.nichols.LN | ||
| Number: | rdar://27874629 | Date Originated: | 16-Aug-2016 11:14 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | Xcode 8.0 beta 6 (8S201h) |
| Classification: | Critical | Reproducible: | Always |
Summary: When modally presenting a UIViewController with the modalPresentationStyle set to UIModalPresentationCustom and the transitioningDelegate returns a custom UIPresentationController subclass. The preferredStatusBarStyle value will not be read from the view controller being presented resulting in no change to the status bar's style. I've attached a sample project where the defect is reproducible. I've replicated this issue on both the iOS simulator and physical devices and it also effects binaries compiled against the iOS 9 SDK that are run on an iOS 10 device. Steps to Reproduce: 1. Download the attached Xcode project. 2. Open the project in Xcode 8. 3. Build and run on an iOS 10 simulator (I used iPhone SE). 4. Tap the "Present with custom transition" 5. Observer that the status bar remains dark after presenting the secondary view controller. Expected Results: SecondViewController will present with a light status bar just like it does when tapping "Present as regular modal" Actual Results: SecondViewController will not adjust it's status bar style from it's presenting view controller's style. Version: Xcode 8.0 beta 6 (8S201h) Notes: Note that running the same code (compiled against the iOS 10 SDK or earlier) on an iOS 9 device or simulator, this will work as expected. This seems to be a bug within iOS 10 so i'm not sure if i've categorised it correctly or not. Configuration: iOS Simulator (iOS 10) Attachments: 'StatusBar.zip' was successfully uploaded.
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!
Solution suggestion
Have you tried
presentedViewController.modalPresentationCapturesStatusBarAppearance = YES;This solution worked for me.
Since I don't have the exact copy of your sample project above, make sure that you are setting the proper view controller that overrides the status bar style.
For example, if the presented controller is a navigation controller with RootViewController as the root view controller, then you would need to access the RootViewController's instance and set modalPresentationCapturesStatusBarAppearance to YES (e.g., [((UINavigationController *) self.presentedViewController) visibleViewController]).
This definitely fixed the issue for our application.
Hope that helps!
Update
Liam Nichols22-Aug-2016 11:36 AM
After a bit of further investigation is has become apparent that the iOS 10 SDK will query the presenting view controller incorrectly at the time of presenting a new modal. This should instead be querying the presented view controller at this point.
Updating preferredStatusBarStyle in ViewController.m of the sample project to the following can provide a work around:
Although this might be a sufficient work around for the sample code, the bug is still present (and it breaks existing binaries on the app store!). It's also a huge inconvenience to go around and add the above bit of code to every view controller in my existing projects.