简体   繁体   English

导航栏按钮项不可见但可操作 iOS Swift

[英]Navigation barButton item not visible but Actionable iOS Swift

Here is my code for rightBarButton item:这是我的 rightBarButton 项目代码:

let rightBarButton = UIBarButtonItem(
            title: "Apply",
            style: .plain,
            target: self,
            action: #selector(saveShotData)
        ) 
    navigationItem.rightBarButtonItem = rightBarButton

Have you tried:你有没有尝试过:

rightBarButton.isHidden = false

if you want it to be hidden and not working, then try如果您希望它被隐藏并且不起作用,请尝试

rightBarButton.isUserInteractionEnabled = false

isHidden only hides - it does not disable. isHidden 仅隐藏 - 它不会禁用。 And unfortunately.isHidden doesn't adjust layout / hide the button - so if you have two right bar button items, they layout doesn't nicely update - though there are creative ways you can get around that if required.不幸的是.isHidden 不调整布局/隐藏按钮 - 所以如果你有两个右栏按钮项目,它们的布局不会很好地更新 - 尽管如果需要,你可以通过创造性的方式解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM