【问题标题】:Zoom in/out gesture UIView放大/缩小手势 UIView
【发布时间】: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


【解决方案1】:

问题是 uiview 需要它的属性 self.multipleTouchEnabled = YES;出于这个原因,多点触控工作但不是那么好。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-02
    • 2017-04-08
    • 2016-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多