@selector()在SWIFT?我想创造一个NSTimer在……里面Swift但我有点麻烦。NSTimer(timeInterval: 1, target: self, selector: test(), userInfo: nil, repeats: true)test()是同一个类中的函数。我在编辑器中发现了一个错误:无法找到接受所提供的参数的“init”重载当我改变selector: test()到selector: nil错误消失。我试过:selector: test()selector: testselector: Selector(test())但什么都没用,我在推荐信中找不到解决办法。
3 回答
回首忆惘然
TA贡献1847条经验 获得超11个赞
Selector
override func viewDidLoad() { super.viewDidLoad() var rightButton = UIBarButtonItem(title: "Title", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("method")) self.navigationItem.rightBarButtonItem = rightButton}func method() { // Something cool here }
温温酱
TA贡献1752条经验 获得超4个赞
var rightButton = UIBarButtonItem(title: "Title", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("method")) @objc func method() { // Something cool here }
- 3 回答
- 0 关注
- 936 浏览
添加回答
举报
0/150
提交
取消