Skip to content

Commit f2d943d

Browse files
authored
fix(iOS): fix setPage issue (#651)
1 parent 7ff5c15 commit f2d943d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

ios/Fabric/RNCPagerViewComponentView.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ - (void)setPageWithoutAnimation:(NSInteger)index {
176176
- (void)goTo:(NSInteger)index animated:(BOOL)animated {
177177
NSInteger numberOfPages = _nativeChildrenViewControllers.count;
178178

179+
_nativePageViewController.view.userInteractionEnabled = NO;
180+
179181
_destinationIndex = index;
180182

181183

@@ -210,6 +212,7 @@ - (void)setPagerViewControllers:(NSInteger)index
210212
int position = (int) index;
211213
strongEventEmitter.onPageSelected(RNCViewPagerEventEmitter::OnPageSelected{.position = static_cast<double>(position)});
212214
strongSelf->_currentIndex = index;
215+
strongSelf->_nativePageViewController.view.userInteractionEnabled = YES;
213216
}
214217
}];
215218
}

ios/ReactNativePageView.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ - (void)setReactViewControllers:(NSInteger)index
178178

179179
if (finished) {
180180
strongSelf.animating = NO;
181+
strongSelf.reactPageViewController.view.userInteractionEnabled = YES;
181182
}
182183

183184
if (strongSelf.eventDispatcher) {
@@ -225,6 +226,8 @@ - (void)updateDataSource {
225226
- (void)goTo:(NSInteger)index animated:(BOOL)animated {
226227
NSInteger numberOfPages = self.reactSubviews.count;
227228

229+
_reactPageViewController.view.userInteractionEnabled = NO;
230+
228231
_destinationIndex = index;
229232

230233
if (numberOfPages == 0 || index < 0 || index > numberOfPages - 1) {

0 commit comments

Comments
 (0)