隐藏或删除导航栏按钮项目中的特定项目,Swift 4 [英] Hide or remove specific item from navigation bar button items, Swift 4

查看:32
本文介绍了隐藏或删除导航栏按钮项目中的特定项目,Swift 4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从故事板中提供的导航栏中隐藏或删除特定按钮项UIBarButtonItem.

Hide OR remove specific button item from navigation bar UIBarButtonItem which is given from storyboard.

例如,右侧导航栏项目我添加了 3 个 UIBarButtonItem,例如故事板中的完成"、取消"、下一步",现在我想从故事板中删除或隐藏取消"按钮根据用户登录以编程方式导航栏,那么我该怎么办?

For example right side navigation bar item I have added 3 UIBarButtonItem like "Done", "Cancel", "next" from storyboard and now I want to remove or Hide "Cancel" button from the navigation bar programmatically as per the user login, So what can I do for this issue?

推荐答案

试试这个:

self.navigationItem.rightBarButtonItems?.remove(at: [indexOfButton])

[indexOfButton] 应该是 rightBarButtonItems 数组中按钮的索引.

[indexOfButton] should be the index of the button in the rightBarButtonItems array.

这篇关于隐藏或删除导航栏按钮项目中的特定项目,Swift 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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