虽然检测到更改与UIControlEventValueChanged
一起使用 - 我甚至需要检测所选段的触摸。
我试过
[onOffSC addTarget:self
action:@selector(segmentedControlPushed)
forControlEvents:UIControlEventAllTouchEvents];
但这什么都没有。
有没有办法检测所选细分受众群的触摸?
编辑 - 无需创建新的子类。 ps手势识别器在尝试将其拖动到那里时也不接受segmentcontrol
非常感谢
答案 0 :(得分:2)
我认为这会起作用
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSInteger oldValue = self.selectedSegmentIndex;
[super touchesBegan:touches withEvent:event];
if ( oldValue == self.selectedSegmentIndex )
[self sendActionsForControlEvents:UIControlEventValueChanged];
}