how to detect touches on uisegmentedcontrol - even on selected segment?
虽然检测更改与
我尝试了
1 2 3 | [onOffSC addTarget:self action:@selector(segmentedControlPushed) forControlEvents:UIControlEventAllTouchEvents]; |
但这不会触发。
有没有一种方法可以检测选定段上的触摸?
编辑-无需创建新的子类。
ps手势识别器在尝试将它拖到那里时也不接受segmentcontrol
非常感谢
我认为这会起作用
1 2 3 4 5 6 7 | -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSInteger oldValue = self.selectedSegmentIndex; [super touchesBegan:touches withEvent:event]; if ( oldValue == self.selectedSegmentIndex ) [self sendActionsForControlEvents:UIControlEventValueChanged]; } |