[英]Disabling a Button to gray color-Objective C
嗨,我是目標 C 的新手。我使用界面生成器創建了兩個按鈕。我沒有編寫兩個 UIButton 動作,而是將兩個按鈕都指向 -(IBAction)buttonPressed:(id)sender;如果我按下一個按鈕,那么其他按鈕應該被禁用(顯示灰色並且不允許點擊)。如何設置這個。[button1 setEnabled:NO]會做。但是如何檢查哪個按鈕被按下了。它像(button.isSelected:YES) .以及如何將其設置為灰色。
- (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!!";
}
}
處理請求不會打印在 UITextView 上。
sender
參數是發送操作的按鈕。
if (sender == myButton) {
[myEventLog setEnabled:NO];
} else if (sender == myEventLog) {
[myButton setEnabled:NO];
}
假設 myButton 和 myEventLog 是您的按鈕。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.