12207480 / TYCyclePagerView

a simple and usefull cycle pager view ,and auto scroll banner view(轮播图) ,include pageControl for iOS,support Objective-C and swift
MIT License
1.79k stars 329 forks source link

偶发调用[weakself.pagerView scrollToItemAtIndex:index animate:YES];无效 #88

Closed git-timor closed 4 years ago

git-timor commented 4 years ago

点击按钮,切换相应的collection界面。 点击按钮时调用如下方法,调用scrollToItemAtIndex:index,偶发无效。 如果将animate 设置为NO则正常。

- (void)topBtnClick:(NSInteger)index{
    __weak typeof (self) weakself = self;
    [UIView animateWithDuration:0.3 animations:^{
        [weakself.pagerView reloadDataNeedResetIndex];
    } completion:^(BOOL finished) {
        [weakself.pagerView scrollToItemAtIndex:index animate:YES];
    }];
}
git-timor commented 4 years ago

在调用scrollToItemAtIndex 之前可以调用 [weakself.pagerView scrollToNearlyIndexAtDirection:TYPagerScrollDirectionRight animate:YES];可解决