ios - Swift 4.2 - 此类与 UITapGestureRecognizer 上的键的键值编码不兼容
问题描述
我有一个像这样的 UITapGestureRecognizer:
let tap = UITapGestureRecognizer(target: self, action: #selector(self.commentsPressed))
self.comments.addGestureRecognizer(tap)
self.comments 是一个 UILabel 和 self.commentsPressed 看起来像这样:
@objc func commentsPressed(recognizer: UITapGestureRecognizer) {
let viewController = storyboard?.instantiateViewController(withIdentifier: "Comments") as! CommentsController
viewController.postid = postid
viewController.disabled = self.commentsDisabled
viewController.userid = self.userid
viewController.coverImageString = self.coverImageString
self.navigationController?.pushViewController(viewController, animated: true)
}
但是当我按下我的 UILabel 时,我得到了这个错误:
此类与键 commentButton 的键值编码不兼容。
在我将代码转换为 Swift 4.2 之前,这是有效的,现在它突然不工作了,我做错了什么,我该如何解决?
解决方案
推荐阅读
- abap - FPM - WD - LPD:POWL 作为 Listpopup 选择一条记录然后返回它
- php - 用 PHP 读取 xls 文件的最简单方法
- angular - 修改数组对象的 Observable 内容
- git - `git commit --amend -F file`之后的`git-review` - 一个新的评论?
- reactjs - 我应该为 createBrowserHistory 提供一个单独的 history.js 吗?
- javascript - 使用节点js单击超链接href时如何重定向到另一个页面?
- sql - 当值大于0时如何避免每次初始化
- jquery - 选择标签中的“其他”选项时显示隐藏字段
- raspberry-pi - Raspberry pi:如何将 v2 noir 相机与 IR 灯相结合
- excel - VBA:将范围与行插入和合并相结合