Search code examples
swiftios13xcode11

UIScreenEdgePanGestureRecognizer won't work in iOS 13 simulator


The UIScreenEdgePanGestureRecognizer won't call its action selector when I deploy on the iOS 13 simulator. The same code works for iOS 12 simulator devices and on real iOS 13 hardware.

override func viewDidLoad() {
  super.viewDidLoad()

  let edgePan = UIScreenEdgePanGestureRecognizer(target: self, action: #selector(screenEdgeSwiped))
    edgePan.edges = .left
    view.addGestureRecognizer(edgePan)
}

@objc func screenEdgeSwiped(_ recognizer: UIScreenEdgePanGestureRecognizer) {
  if recognizer.state == .recognized {
    print("swipe gesture recognized ✔︎")
  }
}

I've created a small sample project. Swiping in the iOS 12 simulator works. In the iOS 13 simulator the selector method screenEdgeSwiped won't be called.


Solution

  • Try enabling Window > Show Device Bezels for the iOS Simulator. I filed a bug with Apple regarding this feature not working as it did previously (FB7253111) but they said this was an intentional change.