How do you set an iPhone UIButton to the selected state, i.e. where it is blue highlighted?
A:
Set the selected property to YES like this :
theButton.selected = YES;
MathieuF
2010-09-29 14:00:41
A:
I'd recommend for simple questions like this you start by looking at the documentation provided by apple. Every class has a reference document which should be your first port of call.
Granted UIButton's documentation does not actually cover the selected
property but that is where you check the documentation for the classes it inherits from.
Inherits from UIControl : UIView : UIResponder : NSObject
And in this case it is UIControl that has the property you are looking for.
myButton.selected = YES;
willcodejavaforfood
2010-09-29 14:08:22
Hi - it does seem obvious.
WaterBoy
2010-09-30 23:38:31
But I did check the documentation and I did use that line of code but it didn't work. So I presumed there was some kind of limitation?
WaterBoy
2010-09-30 23:39:01
As a little more background, there is a second thread operating in the background which is communicating across a stream. So i think the issue is updating the GUI, even though it is the main thread which picks up the button press event, I can't seem to hold the button in a pressed state (is that the same as selected?)
WaterBoy
2010-09-30 23:48:17