首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UITapGestureRecognizer

UITapGestureRecognizer
EN

Stack Overflow用户
提问于 2010-10-14 18:26:48
回答 2查看 660关注 0票数 0

方法获取视图中的位置。

代码语言:javascript
复制
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
}

方法?

EN

回答 2

Stack Overflow用户

发布于 2011-03-15 08:25:18

手势识别器具有locationInView:view方法。此外,UIGestureRecognizer还具有.view属性,因此您可以使用它。

票数 0
EN

Stack Overflow用户

发布于 2016-06-17 22:58:54

下面是一个例子。

代码语言:javascript
复制
-(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];
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3932199

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档