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.