@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 關注
- 978 瀏覽
添加回答
舉報
0/150
提交
取消
