【发布时间】:2009-04-29 19:03:41
【问题描述】:
我一直在尝试在 UIView 中捕捉手势放大/缩小。
代码:
NSSet *allTouches = [event allTouches];
NSArray *twoTouches = [allTouches allObjects];
UITouch *first = [twoTouches objectAtIndex:0];
UITouch *second = [twoTouches objectAtIndex:1];
CGPoint firstPoint = [first locationInView:self];
CGPoint secondPoint = [second locationInView:self];
CGFloat initialDistance = [distanceBetweenPoints(firstPoint, secondPoint)];
我正在使用函数 distanceBetweenPoints,问题是 firstPoint 或 secondPoint 始终为 0.00、0.00,因此结果是其中一个的值。
我需要将展位值设为零才能获得实际距离。
视图的框架为:(0, 0, 320, 417)。
我正在开发的功能类似于放大/缩小谷歌地图。
谢谢,
【问题讨论】:
-
我们在谈论什么平台?苹果手机?
-
是的,iphone。我找到了答案。问题是 uiview 需要它的属性 self.multipleTouchEnabled = YES;出于这个原因,多点触控工作但不是那么好。谢谢,
-
请,当您自己找到答案时,请将其添加为答案,而不是评论。否则,您的问题在搜索中似乎没有答案。
标签: events uiview zooming multi-touch