I have a UISegmentedControl
in a UIView
in my popover that I want to disable in some cases. The segmented control is set up with Interface Builder in a nib file. Its IB "Enabled" checkbook is checked.
To disable it, I wrote:
self.segmentedControl.enabled = NO; // or YES when I want it enabled
Which works to the extent that from there on the segmented control doesn't react to touch events.
However, there is no graphic feedback whatsoever. I would like the segmented control to dim (gray out) when it's disabled. I tried to set its highlighted
property to NO
as well, with no effect.
This should be possible as disabling the UISegmentedControl
with Interface Builder produces the dimming effect that I want.
However, if I do that, my code then cannot re-enable it:
self.segmentedControl.enabled = YES;
will not make it enabled: even though it will start accepting touch events again, it will stay dimmed.
It's as if the IB "enabled" check box controller two properties: enabled
and dimmed
. But what is this dimmed
property that I can't find?
What did I miss?
This is in the 4.3 iPad simulator.
(note that I am talking about the whole control, not its individual segments).
Edit: I investigated a bit further and I found out that disabling the segmented control in IB also sets its alpha
property to 0.5.
When adding:
self.segmentedControl.alpha = 0.5; // or 1.0 if enabled
My app now seems to behave normally.
Am I right to think that setting the enabled
property should also take care of the screen appearance?
I found that this works for each segment:
[self.segmentedControl setEnabled:NO forSegmentAtIndex:0];
The effect is subtle, but it does grey it out. To do all segments:
for(int index=0; index<self.segmentedControl.numberOfSegments; index++)
{
[self.segmentedControl setEnabled:NO forSegmentAtIndex:index];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With