Skip to content
This repository has been archived by the owner on Apr 24, 2022. It is now read-only.

fix the selected item not call scrollViewDidScroll method inside scroll... #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions ICViewPager/ICViewPager/ViewPagerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ @interface ViewPagerController () <UIPageViewControllerDataSource, UIPageViewCon
@property (nonatomic) NSUInteger activeContentIndex;

@property (getter = isAnimatingToTab, assign) BOOL animatingToTab;
@property (getter = isShouldClicked, assign) BOOL shouldClicked;
@property (getter = isDefaultSetupDone, assign) BOOL defaultSetupDone;

// Colors
Expand Down Expand Up @@ -233,6 +234,8 @@ - (IBAction)handleTapGesture:(id)sender {
UIView *tabView = tapGestureRecognizer.view;
__block NSUInteger index = [self.tabs indexOfObject:tabView];

self.shouldClicked = YES;

//if Tap is not selected Tab(new Tab)
if (self.activeTabIndex != index) {
// Select the tab
Expand Down Expand Up @@ -386,6 +389,7 @@ - (void)setActiveContentIndex:(NSUInteger)activeContentIndex {
animated:YES
completion:^(BOOL completed) {

weakSelf.shouldClicked = NO;
weakSelf.animatingToTab = NO;

// Set the current page again to obtain synchronisation between tabs and content
Expand All @@ -403,6 +407,7 @@ - (void)setActiveContentIndex:(NSUInteger)activeContentIndex {
direction:(activeContentIndex < self.activeContentIndex) ? UIPageViewControllerNavigationDirectionReverse : UIPageViewControllerNavigationDirectionForward
animated:YES
completion:^(BOOL completed) {
weakSelf.shouldClicked = NO;
weakSelf.animatingToTab = NO;
}];
}
Expand Down Expand Up @@ -579,7 +584,7 @@ - (void)selectTabAtIndex:(NSUInteger)index {
return;
}

self.animatingToTab = YES;
self.animatingToTab = NO;

// Set activeTabIndex
self.activeTabIndex = index;
Expand Down Expand Up @@ -758,6 +763,7 @@ - (void)defaultSettings {
self.pageViewController.delegate = self;

self.animatingToTab = NO;
self.shouldClicked = NO;
self.defaultSetupDone = NO;
}
- (void)defaultSetup {
Expand Down Expand Up @@ -965,7 +971,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
[self.actualDelegate scrollViewDidScroll:scrollView];
}

if (![self isAnimatingToTab]) {
if (![self isAnimatingToTab] && !self.shouldClicked) {
UIView *tabView = [self tabViewAtIndex:self.activeTabIndex];

// Get the related tab view position
Expand Down