'How to handle alert after video recording duration reached in Swift?
I am trying to limit video recording to 10 seconds in Swift. The problem is when the duration is reached, iPhone will end up with an error like alert. How can I handle this so that it alerts are not shown?
Here is the code I'm using:
func makeUIViewController(context: UIViewControllerRepresentableContext<ImagePicker>) -> UIImagePickerController{
let picker = UIImagePickerController()
picker.delegate = context.coordinator
picker.sourceType = sourceType
picker.mediaTypes = ["public.movie"]
picker.allowsEditing = true
picker.videoMaximumDuration = 10
return picker
}
This is the end result when time reached:
Solution 1:[1]
you can change picker.allowsEditing = false to hide the alert message showing at the bottom i.e., VIDEO_TOO_LONG_TITLE - Please select a smaller clip from this video.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Akshay Kumar Karanam |

