每次滚动 UIScrollView 时,我都必须更新标签的文本……或者每次滚动并让它停在自己的某个点时。标签文本的更新是基于滚动视图的 contentoffset 完成的。所以现在我在每个方法中进行检查:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
int one = scrollView.contentOffset.x/21;
int two = (21*one)+14;
CGPoint point = CGPointMake(two, scrollView.contentOffset.y);
[scrollView setContentOffset:point animated:YES];
[self setLabelText:@"scroll"];
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
int one = scrollView.contentOffset.x/21;
int two = (21*one)+14;
CGPoint point = CGPointMake(two, scrollView.contentOffset.y);
[scrollView setContentOffset:point animated:YES];
[self setLabelText:@"scroll"];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
CGPoint offset = scrollView.contentOffset;
if (offset.x < minuteScrollMinX) offset.x = minuteScrollMinX;
if (offset.x > minuteScrollMaxX) offset.x = minuteScrollMaxX;
scrollView.contentOffset = offset;
}
现在在这之后,我的滚动视图变得太生涩了,我怎样才能防止滚动视图的这种生涩滚动?是否有一个共同的委托而不是这三个方法甚至前两个方法?提前感谢您的帮助。