While detecting changes works with UIControlEventValueChanged
- I need to detect touches even on selected segments.
I tried
[onOffSC addTarget:self
action:@selector(segmentedControlPushed)
forControlEvents:UIControlEventAllTouchEvents];
But this fires nothing.
Is there a way to detect touches on a selected segment?
EDIT - without having to create a new subclass. ps also the gesture recognizer does not accept the segmentcontrol when trying to drag it there
Many thanks
I think this will work
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSInteger oldValue = self.selectedSegmentIndex;
[super touchesBegan:touches withEvent:event];
if ( oldValue == self.selectedSegmentIndex )
[self sendActionsForControlEvents:UIControlEventValueChanged];
}
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