I have a slider
below webView
. What will be shown on the webView depends on slider's value.
I am sliding and it works OK. I want to prevent my app, or more precisely my webView, doing anything while my finger is on slider(while I am moving a slider's circle). Then, after I finish sliding(remove my finger out of the slider's circle), app/webView should be able to do other things. Is this possible?
@IBAction func sliderButton(_ sender: Any) {
loadWebView()
}
sliderButton()
method triggers when user is sliding, but I want loadWebView()
method to be called only after user stops sliding.
For slider, you can do something like this,
sliderButton.addTarget(self, action: #selector(onSliderValChanged(slider:event:)), for: .valueChanged)
@objc func onSliderValChanged(slider: UISlider, event: UIEvent) {
if let touchEvent = event.allTouches?.first {
switch touchEvent.phase {
case .began:
// handle drag began
print("handle drag began")
break
case .moved:
// handle drag moved
print("handle drag moved")
break
case .ended:
// handle drag ended
print("handle drag ended")
//do for `WKWebView`'s user interaction
break
default:
break
}
}
}