Restore cancleable back gesture for those VC's that use it

// FREEBIE
pull/1/head
Michael Kirk 8 years ago committed by Matthew Chen
parent 49c652ad14
commit 7ad5f15448

@ -7,7 +7,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@interface OWSNavigationController (OWSNavigationController) <UINavigationBarDelegate, NavBarLayoutDelegate> @interface UINavigationController (OWSNavigationController) <UINavigationBarDelegate, NavBarLayoutDelegate>
@end @end
@ -106,7 +106,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
[super viewDidLoad]; [super viewDidLoad];
// self.interactivePopGestureRecognizer.delegate = self; self.interactivePopGestureRecognizer.delegate = self;
} }
#pragma mark - UINavigationBarDelegate #pragma mark - UINavigationBarDelegate
@ -114,51 +114,48 @@ NS_ASSUME_NONNULL_BEGIN
// All OWSNavigationController serve as the UINavigationBarDelegate for their navbar. // All OWSNavigationController serve as the UINavigationBarDelegate for their navbar.
// We override shouldPopItem: in order to cancel some back button presses - for example, // We override shouldPopItem: in order to cancel some back button presses - for example,
// if a view has unsaved changes. // if a view has unsaved changes.
//- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item - (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item
//{ {
// OWSAssert(self.interactivePopGestureRecognizer.delegate == self); OWSAssert(self.interactivePopGestureRecognizer.delegate == self);
// UIViewController *topViewController = self.topViewController; UIViewController *topViewController = self.topViewController;
//
// // wasBackButtonClicked is YES if the back button was pressed but not // wasBackButtonClicked is YES if the back button was pressed but not
// // if a back gesture was performed or if the view is popped programmatically. // if a back gesture was performed or if the view is popped programmatically.
// BOOL wasBackButtonClicked = topViewController.navigationItem == item; BOOL wasBackButtonClicked = topViewController.navigationItem == item;
// BOOL result = YES; BOOL result = YES;
// if (wasBackButtonClicked) { if (wasBackButtonClicked) {
// if ([topViewController conformsToProtocol:@protocol(OWSNavigationView)]) { if ([topViewController conformsToProtocol:@protocol(OWSNavigationView)]) {
// id<OWSNavigationView> navigationView = (id<OWSNavigationView>)topViewController; id<OWSNavigationView> navigationView = (id<OWSNavigationView>)topViewController;
// result = ![navigationView shouldCancelNavigationBack]; result = ![navigationView shouldCancelNavigationBack];
// } }
// } }
//
// // If we're not going to cancel the pop/back, we need to call the super // If we're not going to cancel the pop/back, we need to call the super
// // implementation since it has important side effects. // implementation since it has important side effects.
// if (result) { if (result) {
// // NOTE: result might end up NO if the super implementation cancels the // NOTE: result might end up NO if the super implementation cancels the
// // the pop/back. // the pop/back.
// [super navigationBar:navigationBar shouldPopItem:item];
// // MJK WTF?? This seems super broken. It won't compile now, but how could it ever result = YES;
// // have? This is a delegate method, so how are we calling it on super? }
// // [super navigationBar:navigationBar shouldPopItem:item]; return result;
// result = YES; }
// }
// return result;
//}
#pragma mark - UIGestureRecognizerDelegate #pragma mark - UIGestureRecognizerDelegate
// We serve as the UIGestureRecognizerDelegate of the interactivePopGestureRecognizer // We serve as the UIGestureRecognizerDelegate of the interactivePopGestureRecognizer
// in order to cancel some "back" gestures - for example, // in order to cancel some "back" gestures - for example,
// if a view has unsaved changes. // if a view has unsaved changes.
//- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
//{ {
// UIViewController *topViewController = self.topViewController; UIViewController *topViewController = self.topViewController;
// if ([topViewController conformsToProtocol:@protocol(OWSNavigationView)]) { if ([topViewController conformsToProtocol:@protocol(OWSNavigationView)]) {
// id<OWSNavigationView> navigationView = (id<OWSNavigationView>)topViewController; id<OWSNavigationView> navigationView = (id<OWSNavigationView>)topViewController;
// return ![navigationView shouldCancelNavigationBack]; return ![navigationView shouldCancelNavigationBack];
// } else { } else {
// return YES; return YES;
// } }
//} }
@end @end

Loading…
Cancel
Save