如何在静态UITableViewCell上使用UITapGestureRecognizer?

时间:2015-06-03 16:28:04

标签: ios uitableview swift iboutlet

如何在静态UITapGestureRecognizer上使用UITableViewCell?到目前为止,我刚为静态IBOutlet创建了UITableViewCell

@IBOutlet weak var settingCell: UITableViewCell!

当用户点按此IBOutlet时,我想要触发此UITableViewCell

@IBAction func share(sender: AnyObject) {
    let vc = UIActivityViewController(activityItems: [NSURL(string:"https://www.apple.com/my/itunes/")!], applicationActivities: nil)
    /* If you want to exclude certain types from sharing
    options you could add them to the excludedActivityTypes */
    vc.excludedActivityTypes = [UIActivityTypePostToTwitter]
    self.presentViewController(vc, animated: true, completion: nil)
}

我该怎么做?

2 个答案:

答案 0 :(得分:0)

如果我理解你想要的东西,你不需要使用UITapGestureRecognizer,只需用它的协议(你可能已经制作好)设置tableView,并使用这个函数:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){
     //your action comes in here
}

答案 1 :(得分:0)

如果你需要tripleTap / doubleTap。您应该在customTVC文件中添加手势识别器。

您可能希望从tableViewController传递completionHandler或在customTVC级别处理它。

请注意,您可能需要禁用表格视图行选择

向TVC添加手势识别器与将其添加到任何uiview类似。但请注意,并不总是调用awakeFromNib