代码之家  ›  专栏  ›  技术社区  ›  Vanya

双击查看某些部分

  •  0
  • Vanya  · 技术社区  · 15 年前

    在UIView上的某个位置上双击之后,我需要执行某个任务的功能。我知道如何计算点击的次数,但不知道如何确定哪个地方被点击了,我猜要与为执行此操作指定的视图CGRect进行比较。

    2 回复  |  直到 15 年前
        1
  •  1
  •   Warrior    15 年前

    我们可以用触摸开始检测

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
         NSUInteger numTaps = [[touches anyObject] tapCount];
    UITouch* t;
    
    if([[event allTouches] count]==2)//double tap
        {
         t=[[[event allTouches] allObjects] objectAtIndex:0];
     CGPoint p1=[t locationInView:self.view];
         }
    

    numTaps提供了轻拍的数量。

    P1有点被攻丝了。

    一切顺利。

        2
  •  1
  •   Gyani    15 年前

    使用

    Point point = [touch locationInView:self.view];
    
    推荐文章