开发者

Where to set navigationItem of view controller in navigation stack

开发者 https://www.devze.com 2023-02-07 07:04 出处:网络
I have a traditional navigation based app. Should I set the navigation item of the viewcontroller I\'m pushing in the view controller it self (eg self.navigationItem ...) Or in the view controller whi

I have a traditional navigation based app. Should I set the navigation item of the viewcontroller I'm pushing in the view controller it self (eg self.navigationItem ...) Or in the view controller which is about to be popped (eg myViewController.navigationItem ...)?

Also if I should put it in the view controller that's being pushed, should I set up the navigationItem in the init method,开发者_运维知识库 or viewDidLoad, or somewhere else?


Usually, you don't set the navigationItem directly at all. Instead, you set the navigationItems properties (e.g self.navigationItem.leftBarButtonItem = ...;).

The usual way is to do this in the view controller itself, in its viewDidLoad method.

0

精彩评论

暂无评论...
验证码 换一张
取 消