如果没有传递给方法的事件参数,我如何在TouchDragInside方法中获取触摸位置?
显然这不起作用:
- (IBAction)touchDragInsideDblTapSignBut:(id)sender {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
}
谢谢,
答案 0 :(得分:0)
所以在我的viewDidLoad中我不得不添加:
[_dblTapSignAddBut addTarget:self action:@selector(touchDragInsideDblTapSignButE:event:) forControlEvents:UIControlEventTouchDragInside];
然后创建一个void方法:
- (void) touchDragInsideDblTapSignButE:(id)sender event:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
NSLog(@"Location x%f y%f",location.x,location.y);
}