How to create backBarButtomItem with custom view for a UINavigationController

前端 未结 14 1203
余生分开走
余生分开走 2020-11-29 19:39

I have a UINavigationController into which I push several views. Inside viewDidLoad for one of these views I want to set the self.navigationI

14条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 20:15

    backBarButtonItem is not a read-only property. I'm not sure why it behaves so strangely, and the above is a valid (if less-than-ideal) workaround.

    It behaves strangely because setting a vc's backBarButtonItem doesn't change anything about the appearance of the vc's navigation item - instead, it changes the button that points BACK to the vc. See updating the navigation bar from Apple FMI.

    That said I haven't had a whole lot of luck getting it to work myself. If you look around this site, you'll find some threads that suggest placing code very similar to what you already have immediately before the call to push a new view on the stack. I've had some luck there, but unfortunately not when it comes to using a custom image.

提交回复
热议问题