2

In an iPhone app, we have the ability to hide the navigation bar. By default, calling [self.navigationController setNavigationBarHidden:YES animated:YES] to hide the navigation bar stops the screen edge gesture recognizer self.navigationController.interactivePopGestureRecognizer from working, but in the past I could restore this functionality by setting its delegate to my own (while the bar is hidden) that does this:

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return ![otherGestureRecognizer isKindOfClass:[UIScreenEdgePanGestureRecognizer class]];
}

However, this doesn't work now that the app is using UISplitViewController.

It's unclear if the split view controller is using its own gesture recognizer, or some other issue. I haven't been able to figure out how to make it work.

I can't find any other discussion on this. The most recent posts I've found are years old, e.g. this one, this one, or this one.

What am I missing? How can I get a screen edge interactive gesture to work with UISplitViewController when the navigation bar is hidden?

Dejal
  • 813
  • 6
  • 18

1 Answers1

2

Thank you rubber duck.

Of course, soon after posting that, I figured out the answer: when in compact layout, e.g. on iPhone, the UISplitViewController has a UINavigationController to manage the hierarchy, plus the detail view controller has its own UINavigationController.

So the solution was to use the interactivePopGestureRecognizer of the outer navigation controller (that has multiple view controllers), not the inner one (with only one), thusly:

@objc var parentNavigationController: UINavigationController? {
    return navigationController?.parent as? UINavigationController
}

I hope this helps someone else encountering this issue.

Dejal
  • 813
  • 6
  • 18