从 NavigationItem 中删除 BarButtonItem
我正在创建一个使用导航控制器的应用程序。我已经完成了从导航栏中添加和删除 UIBarButtonItem 的操作。我的左侧有后退按钮,右侧有一个名为(更多)的附加按钮。
现在我的要求是,当我单击“更多”时,我需要在导航栏左侧添加一个“关闭”按钮,并且“后退”按钮应该隐藏。我也完成了这个。
问题是在删除我正在使用的关闭按钮时:
self.navigationItem.leftBarButtonItem = nil;
它也删除了我的后退按钮。我需要保留后退按钮,只想删除该按钮。
我不知道我是否正确,我需要编写用于显示后退按钮返回的代码。或者有什么方法可以在单击“更多”按钮或“关闭”本身时仅删除“关闭”按钮。
谢谢
I am creating an app in which I am using navigation Controller. I had done with adding and removing UIBarButtonItem from the navigation Bar. I have back button at my left side and a additional button at right side named (MORE).
Now my requirement is when I click on the MORE I need to add a CLOSE button on the left side of Navigation Bar and Back button should be hide. I am done with this too.
The problem is while removing the CLOSE button I am using like:
self.navigationItem.leftBarButtonItem = nil;
It removes my back button too. I need to keep back button and only want to remove the button.
I don't know whether I am right and I need to write code for displaying back button back. or is there any way by which I can remove only CLOSE button on the click of MORE button or CLOSE itself.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您点击“更多”按钮,则“后退”按钮应该隐藏,并且“更多”应该添加到导航栏的左侧,因此您可以执行以下操作:
当您想要删除“关闭”按钮并将“后退”按钮设置在之前的位置时,请尝试这样做:
If you tap on MORE button, then BACK button should be hide and MORE should be added on left side of NavBar so you can do this as:
when you want to remove your CLOSE button and set your BACK button at previous place then try this as: