-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[V2] Fix iOS pop gesture when topBar is hidden (#4568)
* Fix iOS pop gesture when nav bar is hidden * Add missing property * Factor out InteractivePopGestureDelegate into its own file * Add missing import * Make sure fix supports hidden and visible nav bars * Minor code style fix
- Loading branch information
Showing
6 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// | ||
// InteractivePopGestureDelegate.h | ||
// ReactNativeNavigation | ||
// | ||
// Created by Arman Dezfuli-Arjomandi on 1/10/19. | ||
// Copyright © 2019 Wix. All rights reserved. | ||
// | ||
// | ||
|
||
// This file is adapted from the following StackOverflow answer: | ||
// https://stackoverflow.com/questions/24710258/no-swipe-back-when-hiding-navigation-bar-in-uinavigationcontroller/41895151#41895151 | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface InteractivePopGestureDelegate : NSObject <UIGestureRecognizerDelegate> | ||
|
||
@property (nonatomic, weak) UINavigationController *navigationController; | ||
@property (nonatomic, weak) id<UIGestureRecognizerDelegate> originalDelegate; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// InteractivePopGestureDelegate.m | ||
// ReactNativeNavigation | ||
// | ||
// Created by Arman Dezfuli-Arjomandi on 1/10/19. | ||
// Copyright © 2019 Wix. All rights reserved. | ||
// | ||
|
||
#import "InteractivePopGestureDelegate.h" | ||
|
||
@implementation InteractivePopGestureDelegate | ||
|
||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { | ||
if (self.navigationController.navigationBarHidden && self.navigationController.viewControllers.count > 1) { | ||
return YES; | ||
} else if (!self.navigationController.navigationBarHidden && self.originalDelegate == nil) { | ||
return YES; | ||
} else { | ||
return [self.originalDelegate gestureRecognizer:gestureRecognizer shouldReceiveTouch:touch]; | ||
} | ||
} | ||
|
||
- (BOOL)respondsToSelector:(SEL)aSelector { | ||
if (aSelector == @selector(gestureRecognizer:shouldReceiveTouch:)) { | ||
return YES; | ||
} else { | ||
return [self.originalDelegate respondsToSelector:aSelector]; | ||
} | ||
} | ||
|
||
- (id)forwardingTargetForSelector:(SEL)aSelector { | ||
return self.originalDelegate; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters