我在Swift 3中搜索了很多選擇器方法,但我對它有很多困惑。swift 3選擇器與參數
1)Selector
& #selector
有什麼區別?
2)如果我用Selector
寫的,這個函數概述意味着不可用?
3)如何通過#selector
方法傳遞參數。
我的代碼
let button = UIButton()
button.addTarget(self, action: #selector(getData(_:true)), for: .touchUpInside)
button.addTarget(self, action: Selector(), for: .touchUpInside)
func getData(_ isShowing:Bool){
}
你能不能幫我清除我的困惑?
感謝您的寶貴時間
與這一個http://stackoverflow.com/questions/41520683/swift-3-unrecognized-selector-sent-to-instance-uibutton –
關於質詢3.比較只需使用'#selector( getData)'不需要指定參數。 –
@LeoDabus,謝謝你的回答,但我必須通過一個值檢查條件。 – user1673099