【发布时间】:2017-09-24 17:23:13
【问题描述】:
当将项目代码更新到 swift 4 时,add.target 方法出现一些错误 我该如何解决这个错误?
//swift3
var chatLogController: ChatLogController? {
didSet {
sendButton.addTarget(chatLogController, action: #selector(ChatLogController.handleSend), for: .touchUpInside)
uploadImageView.addGestureRecognizer(UITapGestureRecognizer(target: chatLogController, action: #selector(ChatLogController.handleUploadTap)))
}
}
【问题讨论】:
-
"get some error" 得到 what 错误?
-
此错误“'#selector' 的参数引用了未暴露给 Objective-C 的实例方法 'handleSend()'”
-
嗯,这就是你的答案。只需阅读错误消息的内容即可!将
@objc放在您的func handleSend...前面(看在上帝的份上,您甚至没有在问题中显示)。 -
但是怎么做呢?我不在这行代码上使用 func
-
不,你在声明时使用它。但是,正如我所说,你没有表现出来。找到你说
func handleSend的地方,按照我说的去做。
标签: ios swift xcode selector swift4