UINavigationController 标题和按钮
我有一个 UINavigationController,在其中推送/显示其他几个 UIViewController。我希望特定的标题和按钮(准确地说是取消按钮,出现在右侧)始终出现在 UINavigationController
的 UINavigationBar
中,无论视图控制器显示在导航控制器中。目前,我已将每个视图控制器的 .title
和 .navigationItem.rightBarButtonItem
设置为相同,但这似乎(a)浪费了很多精力; (b) 当一个新的视图控制器被推入堆栈时,会出现一个简短的动画,其中可以看到标题和按钮以动画方式退出然后再返回 - 显然是不可取的,因为我想让这些项目看起来是静态的并且永远不会改变。
任何建议将不胜感激。
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 greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在 UINavigationController 中设置您需要的所有内容,然后在 UIViewControllers 子类的 viewWillAppear 中粘贴:
Try to set all you need in UINavigationController and then in viewWillAppear of your UIViewControllers subclasses paste: