从枚举类型&enum UIControlEvents'隐式转换到不同的枚举类型' UIControlState' (又名' enum UIControlState')

时间:2014-09-08 10:37:01

标签: ios objective-c xcode uicontrolevents

我正在使用Xcode 5.0.2并在尝试编译我的目标C代码时收到以下警告:

**Implicit conversion from enumeration type 'enum UIControlEvents' to different enumeration type 'UIControlState' (aka 'enum UIControlState')**

警告位于abcLabel.m

[searchBtn setTitleColor:[UIColor whiteColor] forState:**UIControlEventTouchUpInside**];

1 个答案:

答案 0 :(得分:0)

您应该使用UIControlState枚举,例如:

[searchBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];

您可以选择的选项:

enum {
   UIControlStateNormal               = 0,
   UIControlStateHighlighted          = 1 << 0,
   UIControlStateDisabled             = 1 << 1,
   UIControlStateSelected             = 1 << 2,
   UIControlStateApplication          = 0x00FF0000,
   UIControlStateReserved             = 0xFF000000
};
当你想要向控件添加事件时,你应该使用

UIControlEvent,例如按下按钮按钮。