,因爲你從字面上是在比較你的按鈕使用(button1 == UIControlStateSelected)
UIControlStates
整數您收到此錯誤是什麼列舉像這樣:
enum {
UIControlStateNormal = 0,
UIControlStateHighlighted = 1 << 0, // used when UIControl isHighlighted is set
UIControlStateDisabled = 1 << 1,
UIControlStateSelected = 1 << 2, // flag usable by app (see below)
UIControlStateApplication = 0x00FF0000, // additional flags available for application use
UIControlStateReserved = 0xFF000000 // flags reserved for internal framework use
};
正如其他答案中所述,您可以使用:
if (button1.state == UIControlStateSelected)
直接比較整數,或者更簡單地說:
if (button1.isSelected) {
status.text = @"Yay!";
}
else {
status.text = @"Boo!";
}
基本邏輯 - 爲什麼你要到一個按鈕比較整型常量? – 2012-08-15 19:13:04