开发者

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 t开发者_如何转开发he 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜