Actually two questions in one, but occurring together so bear with me...
My iPad (landscape) app presents a modal view controller in the .PageSheet
style, instantiating it programmatically from its storyboard ID. The view controller is a UINavigationController
embedding the actual, custom UIViewController
subclass that displays my app's content:
@IBAction func showDetails(sender:AnyObject)
{
guard let detailsNavigation = storyboard?.instantiateViewControllerWithIdentifier("DetailsNavigationControllerID") as? UINavigationController else {
// Failed to instantiate navigation controller (this should not
// happen); abort:
return
}
guard let detailsViewController = detailsNavigation.topViewController as? DetailsViewController else {
// Top view controller of navigation is not of the right type (this
// should not happen); abort:
return
}
// Configure content view controller:
detailsViewController.title = "MyTitle"
// etc...
// Present the containing navigation controller, modally, as page sheet:
detailsNavigation.modalPresentationStyle = UIModalPresentationStyle.PageSheet
presentViewController(detailsNavigation, animated: true, completion: nil)
}
This view controller, in turn, has a UIButton
that triggers a segue. The segue consists of presenting a third view controller modally, but this time full-screen (with transition "Default", i.e. "Cover Vertical").
I am experiencing two issues:
During the transition, the rounded corners of the presenting page sheet view controller disappear (i.e., become perfectly square). This happens both during presentation and dismissal.
The presented fullscreen view controller (also
UINavigationController
) has the wrong status bar style, and I can't seem to fix it.
The navigation bar for this full-screen, modal navigation controller is defined in IB as Style: Default
, Translucent: true
, Bar tint: Default
(i.e., Clear Color). The bar being almost white, the status bar text should be black (.Default
). However, it stays white (.LightContent
) like in the rest of the app (which has a blue navigation bar throughout).
I have tried the following in the top view controller of the presented navigation:
override func viewDidAppear(animated: Bool)
{
super.viewDidAppear(animated)
self.navigationController?.setNeedsStatusBarAppearanceUpdate()
}
override func preferredStatusBarStyle() -> UIStatusBarStyle
{
return UIStatusBarStyle.Default
}
...to no avail.
(The app has UIViewControllerBasedStatusBarAppearance
set to YES
on Info.plist, and other modal view controllers with light-colored nav bars have their status bar style show appropriately.)
UPDATE 1: I have read this question and some of its answers but still can't get it to work (haven't tried subclassing UINavigationController
), but now I now why preferredStatusBarStyle
isn't being called on the top view controller.
UPDATE 2: I tried presenting the same navigation controller but programmatically, and directly from my (already fullscreen) root view controller -instead of from within the page sheet). Now, the status bar correctly displays black characters. Perhaps I'm better off changing my user interface...