发现在手动调用偏移量contentoffset时,系统总会调用代理方法,因为我在代理方法里写了一下动画,结果会造成轻微的闪一下的感觉,动画感觉不够流畅.网上也没找到调用偏移量时不走代理方法的办法.就自己想了个取巧的办法.直接上代码:
声明属性:
@property(nonatomic,assign)BOOL flag;
在需要手动设置偏移量的地方:
self.flag = YES;
[UIView animateWithDuration:0.2 animations:^{
[weakSelf.bgScrollView setContentOffset:CGPointMake(SCREEN_WIDTH * idx, 0)];
} completion:^(BOOL finished) {
weakSelf.flag = NO;
}];
在代理方法scrollViewDidScroll:里面:
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (self.flag) {
return;
}
//
}