Skip to content

Commit

Permalink
fix segment tap crash
Browse files Browse the repository at this point in the history
  • Loading branch information
cwRichardKim committed Apr 28, 2015
1 parent ff092a4 commit 362ef99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions RKSwipeBetweenViewControllers.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,7 @@ @interface RKSwipeBetweenViewControllers ()

@property (nonatomic) UIScrollView *pageScrollView;
@property (nonatomic) NSInteger currentPageIndex;
/*
During Page Scrolling,we should avoild user to tap the segmentButton to fix the crash.
We find the crash situation:
Launch the demo > scrolling in the first page > and then quickly tap the fourth segment button => the app will crash
So I add isPageScrollingFlag to avoid user to tap the segment button during scrolling to fix the crash.
Thank you for RKSwipBetweenViewControllers.
**/
@property (nonatomic) BOOL isPageScrollingFlag;
@property (nonatomic) BOOL isPageScrollingFlag; //%%% prevents scrolling / segment tap crash

@end

Expand Down Expand Up @@ -180,7 +169,7 @@ -(void)syncScrollView {
//eg: if you're on page 1 and you click tab 3, then it shows you page 2 and then page 3
-(void)tapSegmentButtonAction:(UIButton *)button {

if (!self.isPageScrollingFlag) { // During Page Scrolling,we should avoild user to tap the segmentButton.
if (!self.isPageScrollingFlag) {

NSInteger tempIndex = self.currentPageIndex;

Expand Down Expand Up @@ -291,17 +280,13 @@ -(NSInteger)indexOfController:(UIViewController *)viewController {
return NSNotFound;
}

// =======================================================================
#pragma mark - ScrollViewDelegate 代理函数
// =======================================================================
#pragma mark - Scroll View Delegate

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
self.isPageScrollingFlag = YES;
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
self.isPageScrollingFlag = NO;
}

Expand Down
Binary file not shown.

0 comments on commit 362ef99

Please sign in to comment.