iOS: UIButton setSelected

Right now, I'm using this code:

[btn setTitle:@"disabled" forState:UIControlStateDisabled]; 
[btn setTitle:@"selected" forState:UIControlStateSelected];

How can I let it show the text of "selected"? I found it does not always work when I use

[btn setSelected:YES];.

Can anyone help me? Thanks in advance!!


That code should work fine for the simple case where you either have the button selected (and not highlighted nor disabled) or you have it disabled (and not highlighted nor selected).

Keep in mind that some control states can overlap. if you do not specify images for the overlapped states, the UIControl has to pick one. I'm not sure on the exact algorithm for this, but I'd guess a priorities list and UIControlStateSelected is lower in priorities than UIControlStateDisabled

Need Your Help

differentiate same class name in two diffent jar files

java json blackberry jar

I am developing blackberry application using BlackBerry JDE 5.0.X , in which i am using

Require is not defined error in Visual Studio when using ReactJS

visual-studio reactjs gulp

I have a helloworld.jsx file built successfully into a js file and is included in a page through the script tag.