2016-09-17 71 views
-1

enter image description hereIOS無法將類型的值「()」預期參數類型「串」 SWIFT 3

我已經更新了我的代碼斯威夫特3,現在得到上述錯誤。我認爲selector的調用方式有問題。任何人都請幫助我,什麼是錯的。

+0

找到鏈接,它在哪裏被解釋。 [在Cocoa和Objective-C Swift 3中使用Swift](https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html) –

+3

[@selector( )在Swift?](http://stackoverflow.com/questions/24007650/selector-in-swift) – Moritz

回答

7

只需使用像這樣的swift 3選擇器語法來改變你的選擇器語法。

#selector(self.hideKeyboard) 
2

在Swift 3中,Selector的語法已更改。如果選擇器中沒有參數,則不需要在選擇器名稱後添加圓括號。

let tapGesture = UITapGestureRecognizer(target: self, action: #selector(hideKeyboard)) 
self.view.addGestureRecognizer(tapGesture)