iOS: fix slider cannot scroll in simulator

This commit is contained in:
王劲鹏 2023-06-14 20:06:18 +08:00 committed by osborn
parent d1a799756d
commit 7b979cb2b9
2 changed files with 4 additions and 4 deletions

View File

@ -34,8 +34,8 @@ class SliderStyleDemo extends Panel {
} }
})) }))
setTimeout(() => { // setTimeout(() => {
pager.slidePage(this.context, 2, false); // pager.slidePage(this.context, 2, false);
}, 200) // }, 200)
} }
} }

View File

@ -441,7 +441,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
NSUInteger pageIndex; NSUInteger pageIndex;
if ([self.slideStyle isEqualToString:@"gallery"]) { if ([self.slideStyle isEqualToString:@"gallery"]) {
pageIndex = (NSUInteger) (scrollView.contentOffset.x / self.galleryItemWidth); pageIndex = (NSUInteger) (scrollView.contentOffset.x / self.galleryItemWidth + 0.5f);
scrollView.contentOffset = CGPointMake(pageIndex * self.galleryItemWidth, scrollView.contentOffset.y); scrollView.contentOffset = CGPointMake(pageIndex * self.galleryItemWidth, scrollView.contentOffset.y);
} else { } else {
pageIndex = (NSUInteger) (scrollView.contentOffset.x / scrollView.width); pageIndex = (NSUInteger) (scrollView.contentOffset.x / scrollView.width);