0

I am using Xcode 5.0.2 and getting the following warning when trying to compile my objective C code:

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

The Warning is in abcLabel.m:

[searchBtn setTitleColor:[UIColor whiteColor] forState:**UIControlEventTouchUpInside**];
2
  • you should use UIControlStateNormal (or other in UIControlState enum) instead of UIControlEventTouchUpInside
    – stosha
    Sep 8, 2014 at 10:39
  • write a method for touchUpInside and change the searchBtn Color since there are no such selector for UIButton
    – sreekanthk
    Sep 8, 2014 at 13:01

1 Answer 1

0

You should use UIControlState enumeration, for example:

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

Option you can choose from:

enum {
   UIControlStateNormal               = 0,
   UIControlStateHighlighted          = 1 << 0,
   UIControlStateDisabled             = 1 << 1,
   UIControlStateSelected             = 1 << 2,
   UIControlStateApplication          = 0x00FF0000,
   UIControlStateReserved             = 0xFF000000
};

UIControlEvent you should use when you want to add events to the control, for example handle button press.

4
  • UIControlEventTouchUpInside and UIControlStateHighlighted are working same?
    – Mihir Oza
    Sep 8, 2014 at 13:48
  • No they are not the same. This is taken from apple doc: UIControlEventTouchUpInside = 1 << 6, but from my answer above UIControlStateHighlighted = 1 << 0. As you can see there are different.
    – Greg
    Sep 8, 2014 at 14:00
  • So, What I write instead of UIControlEventTouchUpInside to solve the warning?
    – Mihir Oza
    Sep 8, 2014 at 14:16
  • It's depend what you want your button to appear, but I believe you are after UIControlStateNormal.
    – Greg
    Sep 8, 2014 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.