屏幕顶部边缘的 UIScrollView UIPangestureRecognizer 死区 [英] UIScrollView UIPangestureRecognizer dead zone on top edge of screen

查看:29
本文介绍了屏幕顶部边缘的 UIScrollView UIPangestureRecognizer 死区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如下图所示,在屏幕顶部的死区"内开始拖动时,UIPanGestureRecognizer 不会平移.这很可能是由通知中心引起的.

as shown in the picture below the UIPanGestureRecognizer will not pan when the drag started inside the "dead zone" on the top of the screen. This is most likely caused by the notification center.

touchesMoved:withEvent: 方法确实会被调用,因此应该有一种方法可以在该区域识别平移手势.

The touchesMoved:withEvent: method however does get called, so there should be a way to get pan gestures recognized in this area.

有没有其他人遇到过这个问题,是否有任何解决方法?谢谢你的帮助!

Has anyone else came across this issue, are there any workarounds out there yet? Thanks for any help!

推荐答案

解决了问题.touchesMoved:withEvent: 应该这样实现:

Solved the problem. The touchesMoved:withEvent: should be implemented this way:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches.allObjects objectAtIndex:0];
    CGPoint location = [touch locationInView:self];
    CGPoint previousLocation = [touch previousLocationInView:self];
    CGPoint contentOffset = self.contentOffset;

    contentOffset.x -= location.x - previousLocation.x;
    [self setContentOffset:contentOffset animated:NO];
}

这篇关于屏幕顶部边缘的 UIScrollView UIPangestureRecognizer 死区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆