【发布时间】:2011-12-03 12:14:35
【问题描述】:
好的,我在这里遇到了一个非常奇怪的(对我而言)问题。我的视图中有一个 150x150 按钮,并且我在该按钮上添加了一个 UILongPressGestureRecognizer,因为我需要在按下按钮时获得按下按钮的位置。我的代码如下所示:
-(CGPoint)detectedTouch:(UILongPressGestureRecognizer *)sender {
CGPoint touchPoint = [sender locationInView:button];
return touchPoint;
}
-(void)myAction {
CGPoint touchPoint = [self detectedTouch:myGestureRecognizer];
NSLog(@"touchPoint = %f, %f", touchPoint.x, touchPoint.y);
//do stuff
}
现在,当按钮处于正常视图时,一切正常。但是当按钮在滚动视图上时,它只有在你按下它大约一秒钟时才起作用。如果你发布得太快,日志会给我这个:
touchPoint = nan, nan
任何解决此问题的帮助将不胜感激!
【问题讨论】:
标签: iphone objective-c location touch uigesturerecognizer