0

我使用波纹管代码在 UIWebview 上滚动速度,与以前的滚动相比它很好,但我的 clint 不满意,他这样问

滚动仍然感觉僵硬。

webviews.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;

[webviews loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"site URL"]]];
    webviews.scalesPageToFit =YES;`

有没有增加滚动速度的选项?

4

1 回答 1

0

在你的 UIScrollViewDelegate 上有这些属性

CGPoint lastOffset;
NSTimeInterval lastOffsetCapture;
BOOL isScrollingFast;

然后为您的 scrollViewDidScroll 使用此代码:

- (void) scrollViewDidScroll:(UIScrollView *)scrollView {    
    CGPoint currentOffset = self.currentChannelTableView.contentOffset;
    NSTimeInterval currentTime = [NSDate timeIntervalSinceReferenceDate];

    NSTimeInterval timeDiff = currentTime - lastOffsetCapture;
    if(timeDiff > 0.1) {
        CGFloat distance = currentOffset.y - lastOffset.y;
        //The multiply by 10, / 1000 isn't really necessary.......
        CGFloat scrollSpeedNotAbs = (distance * 10) / 1000; //in pixels per millisecond

        CGFloat scrollSpeed = fabsf(scrollSpeedNotAbs);
        if (scrollSpeed > 0.5) {
            isScrollingFast = YES;
            NSLog(@"Fast");
        } else {
            isScrollingFast = NO;
            NSLog(@"Slow");
        }        

        lastOffset = currentOffset;
        lastOffsetCapture = currentTime;
    }
}
于 2013-06-21T10:23:44.660 回答