I tried to record a video. The message I got is from the following code on the device:
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.allowsEditing = YES;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
imagePickerController.delegate = self;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
Any ideas? I think it should be really easy to take a video. When I start the "Camera" app of the phone I have the choice between video and picture. Shouldn't it be available for my app also?
The problem was the way I was trying to set the mode to video mode.
Instead of using this:
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
I changed it to this:
imagePickerController.mediaTypes =
[NSArray arrayWithObject:(NSString *)kUTTypeMovie];
and it worked.
For Swift 3.0, you have to add below line to support both photo and video
import MobileCoreServices
imagePicker.mediaTypes = [kUTTypeMovie as String, kUTTypeImage as String]
Add to above answers, as Micko mentioned, you need to add MobileCoreServices.framework in your project and ref it in your imagePickerController. For those who want to have a switch under the toolbar in your image shooting view, just set the mediaTypes delegate as follows:
imagePC.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeMovie, (NSString *)kUTTypeImage, nil];
Now, you can have both still image taking and video taking, enjoy!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With