如何在下面的方法中添加检查,以便该方法仅响应事件“UIControlEventTouchUpInside”?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
}
我可以查看活动吗?喜欢
if (event == UIControlEventTouchUpInside)
{
//Do something
}
上面的代码不起作用。有什么建议我可以用这种方法检查特定事件吗?
如何在下面的方法中添加检查,以便该方法仅响应事件“UIControlEventTouchUpInside”?
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
}
我可以查看活动吗?喜欢
if (event == UIControlEventTouchUpInside)
{
//Do something
}
上面的代码不起作用。有什么建议我可以用这种方法检查特定事件吗?
如果您想使用 touch-up-inside 之类的事件,则无需为低级触摸处理而烦恼。而是addTarget
像这样使用:
[button addTarget:self action:@selector(myMethod:) forControlEvents:UIControlEventTouchUpInside];
Assigned tag value for that view or control, where you want to finding touch. And write this code inside touch method:
UITouch *touch = [touches anyObject];
int tagValue =[touch view].tag;
if(tagValue == <YOUR TAG VALUE>){
//perform your action
}