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**];
Neeku
  • 3,646
  • 8
  • 33
  • 43
Mihir Oza
  • 2,768
  • 3
  • 35
  • 61
  • you should use UIControlStateNormal (or other in UIControlState enum) instead of UIControlEventTouchUpInside – stosha Sep 08 '14 at 10:39
  • write a method for touchUpInside and change the searchBtn Color since there are no such selector for UIButton – sreekanthk Sep 08 '14 at 13:01

1 Answers1

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.

Greg
  • 25,317
  • 6
  • 53
  • 62
  • UIControlEventTouchUpInside and UIControlStateHighlighted are working same? – Mihir Oza Sep 08 '14 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 08 '14 at 14:00
  • So, What I write instead of UIControlEventTouchUpInside to solve the warning? – Mihir Oza Sep 08 '14 at 14:16
  • It's depend what you want your button to appear, but I believe you are after UIControlStateNormal. – Greg Sep 08 '14 at 14:45