[英]Hide or remove specific item from navigation bar button items, Swift 4
Hide OR remove specific button item from navigation bar UIBarButtonItem
which is given from storyboard.从故事板提供的导航栏
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?例如,右侧导航栏项目我添加了 3 个
UIBarButtonItem
如故事板中的“完成”、“取消”、“下一步”,现在我想根据用户登录以编程方式从导航栏中删除或隐藏“取消”按钮,所以我可以为这个问题做些什么?
Try this:尝试这个:
self.navigationItem.rightBarButtonItems?.remove(at: [indexOfButton])
[indexOfButton] should be the index of the button in the rightBarButtonItems array. [indexOfButton] 应该是 rightBarButtonItems 数组中按钮的索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.