iphone – 如何检测uisegmentedcontrol上的触摸 – 即使在选定的
发布时间:2020-12-14 19:39:42 所属栏目:百科 来源:网络整理
导读:虽然检测到更改与UIControlEventValueChanged一起使用 – 我甚至需要检测所选段上的触摸. 我试过了 [onOffSC addTarget:self action:@selector(segmentedControlPushed) forControlEvents:UIControlEventAllTouchEvents]; 但这没什么. 有没有办法检测选定细
虽然检测到更改与UIControlEventValueChanged一起使用 – 我甚至需要检测所选段上的触摸.
我试过了 [onOffSC addTarget:self action:@selector(segmentedControlPushed) forControlEvents:UIControlEventAllTouchEvents]; 但这没什么. 有没有办法检测选定细分的触摸? 编辑 – 无需创建新的子类. 非常感谢 解决方法
我认为这会奏效
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSInteger oldValue = self.selectedSegmentIndex; [super touchesBegan:touches withEvent:event]; if ( oldValue == self.selectedSegmentIndex ) [self sendActionsForControlEvents:UIControlEventValueChanged]; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |