【问题标题】:Shorten the touch delay in a UIScrollView?缩短 UIScrollView 中的触摸延迟?
【发布时间】:2011-03-06 01:31:00
【问题描述】:

我希望缩短 UIScrollView 上的触摸延迟,但我不想使用 setDelaysContentTouches:NO;我仍然希望有一点延迟,但我的用户抱怨它太长了。

有没有办法做到这一点?

【问题讨论】:

    标签: iphone uiscrollview touch delay ios


    【解决方案1】:

    我刚刚遇到了这个问题,这是我的解决方案:

    子类 UIScrollView

    添加覆盖这些方法:

    - (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view
    {
    
    
        self.lastTimestamp = [NSDate date];
    
        return [super touchesShouldBegin:touches withEvent:event inContentView:view];
    }
    
    - (BOOL)touchesShouldCancelInContentView:(UIView *)view
    {
          NSDate *now = [NSDate date];
    
    
         if (-[self.lastTimestamp timeIntervalSinceDate:now] < _delay)
            return YES;
    
        return NO;
    }
    

    【讨论】:

      【解决方案2】:

      医生说

      如果用户在计时器之前将手指拖得足够远 过去,滚动视图取消子视图中的任何跟踪,并且 执行滚动本身。子类可以覆盖 touchesShouldBegin:withEvent:inContentView:、pagingEnabled 和 touchesShouldCancelInContentView:方法(由 滚动视图)来影响滚动视图如何处理滚动手势。

      所以我认为没有简单的方法可以做到这一点。您可能必须在这些方法中重新实现整个计时器系统。

      【讨论】:

        猜你喜欢
        • 2011-04-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-01-04
        • 2020-10-21
        • 1970-01-01
        • 1970-01-01
        • 2023-03-06
        相关资源
        最近更新 更多