隐藏导航控制器的rightBarButtonItem [英] Hide the rightBarButtonItem of a navigation controller

查看:172
本文介绍了隐藏导航控制器的rightBarButtonItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何隐藏 UINavigationController rightBarButtonItem ?在我的应用程序中,我有一个编辑按钮,作为 UINavigationController rightBarButtonItem 。我想隐瞒这个?完成某些操作后的UIBarButton`。

Does anyone know how to hide a rightBarButtonItem of a UINavigationController? In my application, I have an edit button as a rightBarButtonItem of a UINavigationController. I want to hide this ? UIBarButton` when some operations are done.

推荐答案

隐藏右键: self.navigationItem.rightBarButtonItem = nil;

现在,要显示它:


  1. 如果您在视图控制器中设置了右键,将其分配给self.editButtonItem,则只需再次指定它以显示它:

  1. If you setup the right button in your view controller by assigning it to self.editButtonItem then simply assign it again in order to show it:

self .navigationItem.rightBarButtonItem = self.editButtonItem;

self.navigationItem.rightBarButtonItem = self.editButtonItem;

如果通过分配和启动UIBarButtonItem在视图控制器中设置右键,则只需保留对视图控制器中的UIBarButtonItem,并在需要显示时再次分配。

If you setup the right button in your view controller by allocating and initing a UIBarButtonItem, then simply keep a reference to the UIBarButtonItem in your view controller, and assign it again when you need to show it.

这篇关于隐藏导航控制器的rightBarButtonItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆