Skip to content

Commit

Permalink
Fix crashes when tab on tab during scrolling tabview
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Bridgman committed Dec 10, 2014
1 parent 4d3ca32 commit 369cd58
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 @@ -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

0 comments on commit 369cd58

Please sign in to comment.