Reputation: 368
I've been searching for hours to find the code that enables/disables a button in xCode 4.2
I am trying to have an if statement inside a button that it either enables or disables a specific button.
I've tried
UIButon *buttonName = (UIButton *) sender;
buttonName.enabled = NO;
(I've read this in an another post)
But the problem with that code is that it disables the button that I have the code inside it and not the button that I want it to disable.
Upvotes: 1
Views: 8594
Reputation: 29216
you have the gist of it...
if you have an instance of your button just set the enabled to false.... the example you are showing is for an event handler, so it will disable the button that is sending the message to you.
in your .h file, you have this button declared and hooked up to your nib:
@property (retain, nonatomic) IBOutlet UIButton *btnMyButton;
now, you can enable/disable like this in your .c file:
btnMyButton.enabled = NO; // disable my button
btnMyButton.enabled = YES; // enable my button
Upvotes: 4