简体   繁体   中英

PanGesture Recognizer not working. [Swift]

I would like to go back to the previous view by using Pangesture (drag view) but I can't. I can do function “pan” only on the left edge of the screen, let's say 5%. The other area of current view the Pangesture function is not working. Is there any way that I can go back to the root view with Pangesture? Please advise. Thank you.

    var pan = UIPanGestureRecognizer(target: self, action: "handlePanGesture:")
    self.mainView.addGestureRecognizer(pan)


  func handlePanGesture(recognizer: UIPanGestureRecognizer) {

    var touchLocation = recognizer.translationInView(self.view)

????

}

Here's an example of a view controller that uses a UIPanGestureRecognizer setup on the storyboard:

在此处输入图片说明 在此处输入图片说明 (Just one inspector shown for example purposes)

ViewController:

class PhotoDetaislViewController: UIViewController {

// the connection
@IBOutlet var swipeRight: UISwipeGestureRecognizer!

override func viewDidLoad() {
    super.viewDidLoad()

//Swipe navigation
    swipeRight.addTarget(self, action: "swipeRight:") // sets up the swipeRight var

}

func swipeRight(sender: UISwipeGestureRecognizer) {

    // do your navigation here

}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM