@selector()在SWIFT?我想創(chuàng)造一個(gè)NSTimer在……里面Swift但我有點(diǎn)麻煩。NSTimer(timeInterval: 1, target: self, selector: test(), userInfo: nil, repeats: true)test()是同一個(gè)類中的函數(shù)。我在編輯器中發(fā)現(xiàn)了一個(gè)錯(cuò)誤:無法找到接受所提供的參數(shù)的“init”重載當(dāng)我改變selector: test()到selector: nil錯(cuò)誤消失。我試過:selector: test()selector: testselector: Selector(test())但什么都沒用,我在推薦信中找不到解決辦法。
3 回答

回首憶惘然
TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超11個(gè)贊
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貢獻(xiàn)1752條經(jīng)驗(yàn) 獲得超4個(gè)贊
var rightButton = UIBarButtonItem(title: "Title", style: UIBarButtonItemStyle.Plain, target: self, action: Selector("method")) @objc func method() { // Something cool here }
- 3 回答
- 0 關(guān)注
- 966 瀏覽
添加回答
舉報(bào)
0/150
提交
取消