Swipe to go back only works on edge of screen?

后端 未结 3 1061
失恋的感觉
失恋的感觉 2020-12-10 22:48

My swipe to go back feature works but only works on the edge of the screen. How can I have it work from anywhere on the screen?

3条回答
  •  一个人的身影
    2020-12-10 23:00

    Swipe to go back is default behavior of pushed/showed view controllers. It works from left edge of the screen (by default). If you want to swipe back from any part of the screen, you should add UISwipeGestureRecognizer to your view:
    let swipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: "didSwipe:") self.view.addGestureRecognizer(swipeGestureRecognizer)

提交回复
热议问题