开发者

UINavigationController title and button

I have a UINavigationController in which I push / display several other UIViewControllers. I would like a specific title and button (a Cancel button to be precise, which appears on the right-hand side) to always appear in the UINavigationController's UINavigationBar regardless of the view controller being displayed within the navigation controller. At the moment I have set the .title and .navigationItem.rightBarButtonItem of each individual view controller to be the same, but this seems like (a) a lot of wasted effort; and (b) when a new view controller is pushed onto the stack there is a brief animation where the title and button can be seen animating out and then back in - obviously not desirable since I want to give the appearance that those items are static and never change.

Any suggestions would be g开发者_C百科reatly appreciated.


Try to set all you need in UINavigationController and then in viewWillAppear of your UIViewControllers subclasses paste:

[self.navigationItem setLeftBarButtonItem:self.navigationController.navigationItem.leftBarButtonItem];
[self.navigationItem setRightBarButtonItem:self.navigationController.navigationItem.rightBarButtonItem];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜