iOS 11 Black Bar Appears on Navigation Bar When Pushing View Controller

Black bar appears under navigation bar

Late answer but I stumbled across this problem today and found your question and it doesn't have an accepted answer yet.

I got this error while going from a prompted viewController to a non prompted viewController in storyboard.

I got that black bar just like you.

And to fix:

// In prompted vc
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
UIView.setAnimationsEnabled(false)
self.navigationItem.prompt = nil
UIView.setAnimationsEnabled(true)
}

This will remove the prompt instantly before switching viewcontroller.

UPDATE

func prompt() -> String? {
return nil
}

override func viewWillAppear(animated: Bool) {
let action = { self.navigationItem.prompt = self.prompt() }

if self.navigationController?.viewControllers.count <= 1 {
UIView.performWithoutAnimation(action)
}
else {
action()
}
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
UIView.performWithoutAnimation {
self.navigationItem.prompt = (segue.destinationViewController as? ViewController)?.prompt()
}
}

Xcode black bar on top of view controller after connecting segue

This is because the segue to the second ViewController is a "show", and the second VC will show like this:

Sample Image

If you want this VC to be full screen, click on the segue you created, change the "Kind" property to "Present Modally", and the "Presenttion" property to "Full Screen":

Sample Image



Related Topics



Leave a reply



Submit