uigesturerecognizer双击tableviewcell + segue swift

时间:2016-02-02 23:00:48

标签: ios swift2

覆盖func prepareForSegue(segue:UIStoryboardSegue,sender:AnyObject?){

    if segue.identifier == "editinfo"{

        let selecteditem: NSManagedObject = items[self.tableView.indexPathForSelectedRow!.row] as! NSManagedObject

        let viewcon: addViewController = segue.destinationViewController as! addViewController

        viewcon.usernameupdate = selecteditem.valueForKey("username") as! String
        viewcon.emailupdate = selecteditem.valueForKey("email") as! String

        viewcon.existeditem = selecteditem

    }

我尝试了以下但是总是在单击时触发了segue

let doubleTap = UITapGestureRecognizer(target: self, action: nil)
       doubleTap.numberOfTapsRequired  = 2
     doubleTap.numberOfTouchesRequired  = 1
       cell.addGestureRecognizer(doubleTap)

1 个答案:

答案 0 :(得分:1)

检查我的代码是否双击,非常简单。

你可以放入一个示例项目,进行调试,或许其他东西阻止你的代码正常工作。

override func viewDidLoad() {
    super.viewDidLoad()

    let doubleTap = UITapGestureRecognizer(target: self, action: "doubleTapHandler")
    doubleTap.numberOfTapsRequired = 2
    view.addGestureRecognizer(doubleTap)
}

func doubleTapHandler() {
    print("double tap")
}