Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes when tab on tab during scrolling tabview #1

Merged
merged 1 commit into from
Dec 10, 2014
Merged
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
16 changes: 11 additions & 5 deletions ICViewPager/ICViewPager/ViewPagerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ @interface ViewPagerController () <UIPageViewControllerDataSource, UIPageViewCon

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

@property BOOL isScrolling;
// Colors
@property (nonatomic) UIColor *indicatorColor;
@property (nonatomic) UIColor *tabsViewBackgroundColor;
Expand Down Expand Up @@ -233,10 +233,13 @@ - (IBAction)handleTapGesture:(id)sender {
UIView *tabView = tapGestureRecognizer.view;
__block NSUInteger index = [self.tabs indexOfObject:tabView];

//if Tap is not selected Tab(new Tab)
if (self.activeTabIndex != index) {
// Select the tab
[self selectTabAtIndex:index];
// If user is not scrolling tabview
if (!self.isScrolling) {
// If tap is not selected tab (new tab)
if (self.activeTabIndex != index) {
// Select the tab
[self selectTabAtIndex:index];
}
}
}

Expand Down Expand Up @@ -759,6 +762,7 @@ - (void)defaultSettings {

self.animatingToTab = NO;
self.defaultSetupDone = NO;
self.isScrolling = NO;
}
- (void)defaultSetup {

Expand Down Expand Up @@ -997,6 +1001,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
}
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
self.isScrolling = YES;
if ([self.actualDelegate respondsToSelector:@selector(scrollViewWillBeginDragging:)]) {
[self.actualDelegate scrollViewWillBeginDragging:scrollView];
}
Expand Down Expand Up @@ -1028,6 +1033,7 @@ - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
self.isScrolling = NO;
if ([self.actualDelegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) {
[self.actualDelegate scrollViewDidEndDecelerating:scrollView];
}
Expand Down