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
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