PanGesture Recognizer无法正常工作。 [夫特]

时间:2015-08-02 05:52:43

标签: swift uiview uipangesturerecognizer

我想通过使用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)

????

}

1 个答案:

答案 0 :(得分:0)

以下是在故事板上使用UIPanGestureRecognizer设置的视图控制器示例:

enter image description here enter image description here (仅出于示例目的显示一名检查员)

<强>的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

}
}