简体   繁体   中英

navigationBar backButton title present but arrow missing on instantiated viewController

I am pushing from a viewController to another instance of the same viewController using the following code. The viewController is the top view of the navigation stack in the storyboard:

let storyboard = UIStoryboard(name: "Main", bundle: nil)
if let vc2 = storyboard.instantiateViewController(withIdentifier: "MyViewController") as? MyViewController {
    self.navigationController?.pushViewController(vc2, animated: true)
}

When vc2 is pushed to for a moment the back left arrow and title of the backButton is visible but the arrow quickly disappears and only the title is left for the backButton.

I'm assuming that this is because the instantiated viewController is the topViewController in the storyboard.

I tried:

self.navigationItem.hidesBackButton = false

but this didn't work. Not sure how to make the back arrow (carat) be visible in this case. The backButton title continues to be displayed and pressing it correctly returns to the previous view.

just try this

self.navigationItem.leftBarButtonItem = nil

If it doesn't work then check appearance color of navigation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM