nbojja
nbojja

Reputation: 1655

Show or Hide a UIButton in iPhone app with Objective-C

I am using UITextView to edit text. I want to use two UIButtons Edit 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.

I am a c# coder, in c# I used to do like this

C# code
btnedit.visible=true;

Now I want to know how to make a button visible and not visible from objective c code.

Thanks,

Upvotes: 35

Views: 61858

Answers (4)

Biswajit Banik
Biswajit Banik

Reputation: 99

Simply Add IBoutlet property in .h file. like

@property (strong, nonatomic) IBOutlet UIButton *resendOtpButtom;

then add

_resendOtpButtom.hidden = YES; in .m file. 

Upvotes: 0

Benny Wong
Benny Wong

Reputation: 6851

Since UIButton inherits from UIView, you can just set the hidden property on the button (via UIButton doc)

button.hidden = YES;

Upvotes: 106

Marc Charbonneau
Marc Charbonneau

Reputation: 40513

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.

Upvotes: 6

Héctor Ramos
Héctor Ramos

Reputation: 9252

Instead of visible, the property you are looking for is hidden.

saveButton.hidden = YES;

That should do the trick.

Upvotes: 3

Related Questions