![](/img/trans.png)
[英]cannot convert value of type string to expected argument type int in swift 3
[英]ios Cannot convert value of type '()' to expected argument type 'String' swift 3
只需使用swift 3選擇器語法更改您的選擇器語法,如下所示。
#selector(self.hideKeyboard)
在Swift 3中,Selector的語法已更改。如果選擇器中沒有參數,則無需在選擇器名稱后添加圓括號。
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(hideKeyboard))
self.view.addGestureRecognizer(tapGesture)
對於任何尋求解決方案的人都可以嘗試一下。
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
view.addGestureRecognizer(tap)
// function which is triggered when handleTap is called
func handleTap(_ sender: UITapGestureRecognizer) {
print("Hello World")
}
我知道現在回答得太晚了,但是它可以幫助其他人。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.