2016-09-17 72 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)