使用 Objective-C 在 iPhone 应用程序中显示或隐藏 UIButton
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/957821/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Show or Hide a UIButton in iPhone app with Objective-C
提问by nbojja
I am using UITextViewto edit text. I want to use two UIButtonsEdit and Save. Initially I want to show edit UIButton, when the user click on edit I want to show save UIButton. when the content successfully saved I dont want to show save button any more.
我正在使用UITextView编辑文本。我想使用两个UIButtons编辑和保存。最初我想显示 edit UIButton,当用户点击 edit 我想显示 save UIButton。当内容成功保存时,我不想再显示保存按钮。
I am a c# coder, in c# I used to do like this
我是 ac# 编码员,在 c# 中我曾经这样做过
C# code
btnedit.visible=true;
Now I want to know how to make a button visible and not visible from objective c code.
现在我想知道如何从目标 c 代码中使按钮可见和不可见。
Thanks,
谢谢,
回答by Benny Wong
Since UIButtoninherits from UIView, you can just set the hiddenproperty on the button (via UIButton doc)
由于UIButton继承自UIView,您只需hidden在按钮上设置属性(通过UIButton doc)
button.hidden = YES;
回答by Marc Charbonneau
Consider enabling or disabling the buttons instead. You get the same end result, but it's a little bit more consistent since things aren't appearing and dissapearing out of nowhere.
考虑启用或禁用按钮。您会得到相同的最终结果,但它更加一致,因为事物不会凭空出现和消失。
回答by Héctor Ramos
Instead of visible, the property you are looking for is hidden.
您要查找的属性不是可见的,而是隐藏的。
saveButton.hidden = YES;
That should do the trick.
这应该够了吧。
回答by Biswajit Banik
Simply Add IBoutlet property in .h file. like
只需在 .h 文件中添加 IBoutlet 属性。喜欢
@property (strong, nonatomic) IBOutlet UIButton *resendOtpButtom;
then add
然后加
_resendOtpButtom.hidden = YES; in .m file.

