I am new to iOS development but I am trying to follow a raywenderlich.com tutorial on adding animations and overlays to videos but I am getting some unexpected behavior. For some reason when I press the pickButton it takes me to my "Memories" instead of my camera roll (see the image below) in my simulator. What is really strange is that when I run the code the debugger is completely blank. There is nothing that seems to be running according to the debugger, but the app itself appears to be working when I look at it in the simulator. There are several print statements that should display in the debugger but I do not see anything. You can download the entire codebase (its pretty small) from the hyperlink above. I am not sure why this is not working.
@IBAction func pickVideoButtonTapped(_ sender: Any) {
pickVideo(from: .savedPhotosAlbum)
}
private func pickVideo(from sourceType: UIImagePickerController.SourceType) {
let pickerController = UIImagePickerController()
pickerController.sourceType = sourceType
pickerController.mediaTypes = [kUTTypeMovie as String]
pickerController.videoQuality = .typeIFrame1280x720
if sourceType == .camera {
pickerController.cameraDevice = .front
}
pickerController.delegate = self
present(pickerController, animated: true)
}
Where do you call this function private func pickVideo(from sourceType: UIImagePickerController.SourceType)
and what UIImagePickerController.SourceType
are you handing over? Best would be to show us the code that calls the function.
On the other hand, working with the camera and importing images is always kind of difficult on the simulator, since it cannot access the camera and therefore has no images. Try to run the code and an actual device (Your iPhone). Maybe it is working on there.
Try this out, and if not working, provide the code that calls the pickVideo
function.