I'm trying to end a long press gesture without lifting my finger from the screen. Is that possible in swift?
I'm making an app that lets you record video. The video recording starts when i press down on a button and ends when I lift my finger from the screen. That part works perfectly. What I also want is for the long press gesture to end after 30 seconds if my finger is still pressed on the button. I actually got it to stop recording but the problem is that the long press gesture doesn't actually end when the recording stops.
Here's some of my code:
func stop() {
let seconds : Int64 = 5
let preferredTimeScale : Int32 = 1
let maxDuration : CMTime = CMTimeMake(seconds, preferredTimeScale)
movieOutput.maxRecordedDuration = maxDuration
if movieOutput.recordedDuration == movieOutput.maxRecordedDuration {
movieOutput.stopRecording()
}
}
func longTap(_ sender: UILongPressGestureRecognizer){
print("Long tap")
stop()
if sender.state == .ended {
print("end end")
movieOutput.stopRecording()
}
else if sender.state == .began {
print("begin")
captureSession.startRunning()
startRecording()
}
}