简体   繁体   中英

Disabling a Button to gray color-Objective C

Hi, I am new to objective C.I have created two buttons using interface builder.Instead of writing two UIButton actions I have pointed both of the buttons to -(IBAction)buttonPressed:(id)sender;If i press one Button then the other button should be disabled(showing gray and should not allow to click).How to set this.[button1 setEnabled:NO] will do.But how to check which button has been pressed.Is it like (button.isSelected:YES).And How to set that to gray color.

- (IBAction)buttonPressed:(id)sender
{
        if ([myButton.isSelected:YES]) //Invalid receiver type BOOL
          {                            //No '-' method found //cast to pointer to  integer of different size warnings.
                [myEventLog setEnabled:NO];
                myTextView.text = @"Processing the request!!";
        }
}

Processing the request doesnt get printed on the UITextView.

The sender argument is the button that is sending the action.

 if (sender == myButton) {
       [myEventLog setEnabled:NO];
 } else if (sender == myEventLog) {
       [myButton setEnabled:NO];
 }

That's assuming that myButton and myEventLog are your buttons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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