Skip to content

Commit

Permalink
Merge pull request #1 from 3months/bugfix/scrolling-crash
Browse files Browse the repository at this point in the history
Fix crashes when tab on tab during scrolling tabview
  • Loading branch information
timothyrobb committed Dec 10, 2014
2 parents ead467b + 369cd58 commit 76d1b3c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions ICViewPager/ICViewPager/ViewPagerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,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 @@ -219,10 +219,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 @@ -745,6 +748,7 @@ - (void)defaultSettings {

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

Expand Down Expand Up @@ -983,6 +987,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 @@ -1014,6 +1019,7 @@ - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
self.isScrolling = NO;
if ([self.actualDelegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) {
[self.actualDelegate scrollViewDidEndDecelerating:scrollView];
}
Expand Down

0 comments on commit 76d1b3c

Please sign in to comment.