Skip to content

Commit 362ef99

Browse files
committed
fix segment tap crash
1 parent ff092a4 commit 362ef99

2 files changed

Lines changed: 5 additions & 20 deletions

File tree

RKSwipeBetweenViewControllers.m

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,7 @@ @interface RKSwipeBetweenViewControllers ()
2626

2727
@property (nonatomic) UIScrollView *pageScrollView;
2828
@property (nonatomic) NSInteger currentPageIndex;
29-
/*
30-
During Page Scrolling,we should avoild user to tap the segmentButton to fix the crash.
31-
32-
We find the crash situation:
33-
34-
Launch the demo > scrolling in the first page > and then quickly tap the fourth segment button => the app will crash
35-
36-
So I add isPageScrollingFlag to avoid user to tap the segment button during scrolling to fix the crash.
37-
38-
Thank you for RKSwipBetweenViewControllers.
39-
**/
40-
@property (nonatomic) BOOL isPageScrollingFlag;
29+
@property (nonatomic) BOOL isPageScrollingFlag; //%%% prevents scrolling / segment tap crash
4130

4231
@end
4332

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

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

185174
NSInteger tempIndex = self.currentPageIndex;
186175

@@ -291,17 +280,13 @@ -(NSInteger)indexOfController:(UIViewController *)viewController {
291280
return NSNotFound;
292281
}
293282

294-
// =======================================================================
295-
#pragma mark - ScrollViewDelegate 代理函数
296-
// =======================================================================
283+
#pragma mark - Scroll View Delegate
297284

298-
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
299-
{
285+
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
300286
self.isPageScrollingFlag = YES;
301287
}
302288

303-
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
304-
{
289+
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
305290
self.isPageScrollingFlag = NO;
306291
}
307292

0 commit comments

Comments
 (0)