代码:
registerButton.addTarget(self, action: Selector("registerAction"), forControlEvents: UIControlEvents.TouchUpInside) |
警告:
Use ‘#selector’ instead of explicitly constructing a ‘Selector’
改为:
// registerButton.addTarget(self, action: Selector("registerAction"), forControlEvents: UIControlEvents.TouchUpInside) registerButton.addTarget(self, action: #selector(RegisterUsernameViewController.registerAction), forControlEvents: UIControlEvents.TouchUpInside) |
即可。
还有类似的问题:
代码:
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissKeyboard") self.view.addGestureRecognizer(tap) |
警告:
Use of string literal for Objective-C selectors is deprecated; use ‘#selector’ instead
改为:
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(LoginViewController.dismissKeyboard)) |
即可。
转载请注明:在路上 » 【已解决】swift 3:Use ‘#selector’ instead of explicitly constructing a ‘Selector’