ios - 如何在静态 UITableViewCell 上使用 UITapGestureRecognizer?

标签 ios uitableview swift iboutlet

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

@IBOutlet weak var settingCell: UITableViewCell!

我想要的是当用户点击此 UITableViewCell 时触发此 IBOutlet

@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)
}

我该怎么做?

最佳答案

如果我明白你想要什么,你不需要使用 UITapGestureRecognizer,你可以简单地设置 tableView 及其协议(protocol)(你可能已经制定了),并使用这个函数:

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

关于ios - 如何在静态 UITableViewCell 上使用 UITapGestureRecognizer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30625720/

相关文章:

ios - swift alertview textfield - 如何检索输入的文本

iOS 10.0 UIRefreshControl 不显示指示器

ios - 当 UIWebView 完成加载时,如何强制重新布局 UITableViewCell?

ios - 如果在 iOS 上使用系统帐户进行​​身份验证,则无法检索 Twitter 电子邮件

ios - 删除 MagicalRecord 中的实体不会持久存在

ios - 如何在SQLite数据库iOS objective-c 中自动递增

ios - IOS 应用程序的牵线木偶效果

objective-c - 如何使用 Storyboard将 UITableView 添加到多个 subview 之一

ios - 打破 UINavigationController

ios - 简单创建 SCNNode 时 NSSecureCoding 抛出异常