當更新項目代碼到swift 4得到一些錯誤的add.target方法 我該如何解決這個錯誤?如何更新addTarget方法swift 4
//swift3
var chatLogController: ChatLogController? {
didSet {
sendButton.addTarget(chatLogController, action: #selector(ChatLogController.handleSend), for: .touchUpInside)
uploadImageView.addGestureRecognizer(UITapGestureRecognizer(target: chatLogController, action: #selector(ChatLogController.handleUploadTap)))
}
}
「得到一些錯誤」獲取_what_錯誤? – matt
這個錯誤「#selector'的參數是指實例方法'handleSend()'沒有公開到Objective-C」 –
那麼你的答案。只要閱讀錯誤信息說的是什麼!把'@ objc'放在'func handleSend ...'前面(你甚至沒有在你的問題中顯示,看在上帝的份上)。 – matt