有没有办法从轻敲的位置获取cgpoint,而不必使用触摸方法,如触摸开始或触摸移动?我问,因为我有一个内置UITableView的视图,并且由于某种原因,触摸方法似乎没有在表视图中工作。
答案 0 :(得分:2)
您可以使用 UITapGestureRecognizer
你应该把它放在初始化方法中:
UITapGestureRecognizer * = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognized:)];
[theTargetView addGestureRecognizer:tapRecognizer];//theTargetView could also be self.view
目标类中的其他地方:
- (void)tapRecognized:(UITapGestureRecognizer *)recognizer
{
if(recognizer.state == UIGestureRecognizerStateRecognized)
{
CGPoint point = [recognizer locationInView:recognizer.view];
//your coordinates ;)
}
}