我想通过使用Pangesture(拖动视图)回到上一个视图,但我不能。我只能在屏幕的左边缘执行“平移”功能,比方说5%。当前查看Pangesture功能的其他区域无法正常工作。有什么方法可以回到Pangesture的根视图吗?请指教。谢谢。
var pan = UIPanGestureRecognizer(target: self, action: "handlePanGesture:")
self.mainView.addGestureRecognizer(pan)
func handlePanGesture(recognizer: UIPanGestureRecognizer) {
var touchLocation = recognizer.translationInView(self.view)
????
}
答案 0 :(得分:0)
以下是在故事板上使用UIPanGestureRecognizer设置的视图控制器示例:
<强>的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
}
}