簡體   English   中英

PanGesture識別器不起作用。 [迅速]

[英]PanGesture Recognizer not working. [Swift]

我想使用Pangesture(拖動視圖)返回上一個視圖,但我不能。 我只能在屏幕的左邊緣執行“平移”功能,比如說5%。 當前視圖的另一個區域“手勢”功能不起作用。 有什么方法可以使我回到Pangesture的根視圖嗎? 請指教。 謝謝。

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


  func handlePanGesture(recognizer: UIPanGestureRecognizer) {

    var touchLocation = recognizer.translationInView(self.view)

????

}

這是在情節提要板上使用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

}
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM