我使用下面的代码在UIWebview上滚动速度, 相比之前的滚动它的优良和良好,但我的克林特不满意,他问这样
滚动仍感觉僵硬。
webviews.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
[webviews loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"site URL"]]];
webviews.scalesPageToFit =YES;`
有没有提高滚动速度的选项?
答案 0 :(得分: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;
}
}