self.navigationItem.rightBarButtonItem vs self.navigationController.navigationItem.rightBarButtonItem

…衆ロ難τιáo~ 提交于 2019-12-10 19:57:59

问题


I'm somewhat confused about using self.navigationItem.rightBarButtonItem and self.navigationController.navigationItem.rightBarButtonItem.

Which one is correct way?


回答1:


The first, i.e. self.navigationItem.rightBarButtonItem.

Every view controller has an associated navigation item. This is what is displayed in a navigation bar. So it's the current view controller's navigation item that you want to manipulate. If you manipulated the navigation controller's navigation item then that would show if the navigation controller (also a view controller) were itself shown inside another navigation controller.



来源:https://stackoverflow.com/questions/13905618/self-navigationitem-rightbarbuttonitem-vs-self-navigationcontroller-navigationit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!