1

I have an iOS app which holds a wkWebView. This wkWebView has links which can pop open an instance of SafariViewController. When SafariViewController is launched and you swipe right to dismiss sometimes it works but sometimes it goes black.

I've tried multiple variations of setting interactivePopGestureRecognizer.enabled to false. Also setting its delegate to nil.

I have the delegate methods which have break points and none of them get hit.

I want to disable this feature entirely.

mKane
  • 932
  • 13
  • 30
  • Can you share more details on what you're doing? – Chris Droukas Jan 29 '16 at 15:28
  • Just clicking a link from my webview. It displays in SFSafariViewController just fine. I can press done on safari and it closes properly. But if I swipe left it dismisses the controller. Sometimes it works but sometimes the screen ends up black. I just want to disable the swipe left gesture completely – mKane Jan 29 '16 at 15:33
  • 2
    This does come up in the device log. Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service – mKane Jan 29 '16 at 15:42
  • Swipe right** question updated – mKane Jan 29 '16 at 15:44
  • Adding logs it seems like it crashes right after viewWillAppear and viewDidAppear. Weird – mKane Jan 29 '16 at 16:45
  • Finally just called my instance of SFSafariViewController and set the view to not let a user interact. Doesnt solve the crash but it prevents it from happening – mKane Jan 29 '16 at 18:21
  • This is a bug in iOS 9.2+ when the status bar color changes from white to black when SafariViewController is presented. It may be fixed in iOS 9.3 beta. I hacked around this with http://www.stringcode.co.uk/push-pop-modal-sfsafariviewcontroller-hacking-swipe-from-edge-gesture/ for now until Apple Fixes it. – Paul Buchanan Feb 02 '16 at 20:04

2 Answers2

2

It seem likes a bug in iOS. You can try to workaround i.e

Add SafariViewController into the rootController of NavigationController
Then present the NavigationController instead of SafariViewController.
Huy Le
  • 2,503
  • 1
  • 15
  • 15
0

Here's a temporary workaround I'm using to disable the edge swipe gesture. It doesn't seem to be a problem as long as the Done button is used to dismiss.

let viewController = SFSafariViewController(URL: url)  
presentViewController(viewController, animated: true) {  

 for view in viewController.view.subviews {  

      if let recognisers = view.gestureRecognizers {  

           for gestureRecogniser in recognisers where gestureRecogniser is UIScreenEdgePanGestureRecognizer {  

                gestureRecogniser.enabled = false  
           }  
      }  
 }  

}

 OC:
 for (UIView * view in safari.view.subviews) {

            NSArray<__kindof UIGestureRecognizer *> * array = view.gestureRecognizers;
            if (array.count) {
                for (UIScreenEdgePanGestureRecognizer * sepgr in array) {
                    sepgr.enabled = NO;
                }
            }
        }

SFSafariViewController in iOS 9.2 | Apple Developer Forums

iHTCboy
  • 2,715
  • 21
  • 20