!!! 多个手势怎么同时进行??

southbirdfly 2011-10-24 03:33:36
我在controller中添加了两个手势:
UIGestureRecognizer *recognizer;
recognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleRotation:)];
recognizer.cancelsTouchesInView = NO;
[self.scrollView addGestureRecognizer:recognizer];
[recognizer release];

UIGestureRecognizer *recognizer2;
recognizer2 = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinch:)];
recognizer2.cancelsTouchesInView = NO;
[self.scrollView addGestureRecognizer:recognizer2];
[recognizer2 release];


发现每次只能进入Pinch的手势,无法进入Rotation的手势。如果只添加一个,是都可以执行的。
我在Controller中添加了
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}

但发现没有执行。于是在scrollView中添加同样的代码。虽然执行了,但效果还是一样。Pinch和Rotation这两个手势没有同时执行。都是只执行Pinch后没有执行Rotation
请问这是为什么? 怎么让两个手势同时执行?
...全文
211 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
a363211861 2011-11-28
  • 打赏
  • 举报
回复
楼主 我也是用了那个代理方法 用的是一个UILongPressGestureRecognizer和一个UIPanGestureRecognizer也设置delegate = self了 代理方法也写了 返回的是YES;但是还是只响应UIPanGestureRecognizer的方法 请问这是为什么呢
southbirdfly 2011-10-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 one2zero 的回复:]

那就我来接吧

不过为什么要手势覆盖呢
[/Quote]
手势覆盖??
我需要缩放图片的同时可以旋转,这需要不同的手势实现吧?

等下结贴,再没其他人分就全给你了,哈哈
one2zero 2011-10-24
  • 打赏
  • 举报
回复
那就我来接吧

不过为什么要手势覆盖呢
southbirdfly 2011-10-24
  • 打赏
  • 举报
回复
找到原因了,要给手势设置delegate,即:
recognizer.delegate = self;
recognizer2.delegate = self;

谁来接分??

29,049

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧