UIScrollview getting touch events

后端 未结 4 1918
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 20:45

How can I detect touch points in my UIScrollView? The touches delegate methods are not working.

4条回答
  •  迷失自我
    2020-11-28 21:29

    This works also on touch down event.

    In the currently as correct marked answer you can get a touch point only at a "Tap" event. This event seems only to fire on "finger up" not on down.

    From the comment of yuf in the same answer you can get the touch point from the underlying view also within the UIScrollView.

    - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldReceiveTouch:(UITouch*)touch
    {
      CGPoint touchPoint = [touch locationInView:self.view];
    
      return TRUE; // since we're only interested in the touchPoint
    }
    

    According to Apple's documentation the gestureRecognizer does:

    Ask the delegate if a gesture recognizer should receive an object representing a touch.

    which means to me that I can decide if a gestureRecognizer should recieve a touch or not.

提交回复
热议问题