我與UISlider工作,我想認識價值的變化:無法識別的選擇發送到實例,UISlider swfit3
var sliderGeofence: UISlider!
裏面我viewDidLoad()
:
self.sliderGeofence = UISlider(frame: CGRect(x: 20, y: 20, width: self.view.frame.size.width - 50, height: 50))
self.sliderGeofence?.maximumValue = 100000
self.sliderGeofence?.minimumValue = 500
self.sliderGeofence?.value = 100
self.sliderGeofence?.isUserInteractionEnabled=true
self.sliderGeofence?.addTarget(self, action: Selector("geofenceValueChange:"),for: UIControlEvents.valueChanged)
gmsMap.addSubview(self.sliderGeofence!)
sliderGeofence?.isHidden = true
我的價值變化的方法:
@IBAction func geofenceValueChange(sender: AnyObject)
{
print("entro")
}
該應用程序加載滑塊,但是,當我更改其值時發生這種情況:
***終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因是: ' - [MocaAdmin.FirstViewController geofenceValueChange:]:無法識別的選擇發送到實例 0x7fca61511480'
我在做什麼錯誤?
嘗試更改添加目標到:'self.sliderGeofence?.addTarget(self,action:#selector(geofenceValueChange :),for:UIControlEvents.valueChanged)' – Priyal
@Priyal,你在那裏。見下面的Rashwan的答案。選擇器的Swift形式將是'geofenceValueChange(_ :)' –