方法获取视图中的位置。
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
}方法?
发布于 2011-03-15 08:25:18
手势识别器具有locationInView:view方法。此外,UIGestureRecognizer还具有.view属性,因此您可以使用它。
发布于 2016-06-17 22:58:54
下面是一个例子。
-(void)handleGesture:(UIGestureRecognizer *)gestureRecognizer
{
CGPoint p = [gestureRecognizer locationInView:self.navigationController.toolbar];
CGRect nextButtonRect = CGRectMake(self.navigationController.toolbar.frame.size.width * 2 / 3,
0,
self.navigationController.toolbar.frame.size.width / 3,
self.navigationController.toolbar.frame.size.height);
CGRect previousButtonRect = CGRectMake(0,
0,
self.navigationController.toolbar.frame.size.width / 3,
self.navigationController.toolbar.frame.size.height);
if (CGRectContainsPoint(previousButtonRect, p))
[self tapOnPreviousNews];
if (CGRectContainsPoint(nextButtonRect, p))
[self tapOnNextNews];
}https://stackoverflow.com/questions/3932199
复制相似问题