The documentation is not at all clear on how to do this, but it's fairly straightforward.
- Add the MobileCoreServices framework to your project
- Add #import <MobileCoreServices/UTCoreTypes.h> to the header file where you will reference the picker. Alternately, you can add the import to your precompiled header file (.pch) so the UTCoreTypes constants are available throughout the project.
Now, before calling the UIImagePickerController, just set the mediaTypes property to the movie type, kUTTypeMovie. Or, if you wanted to only display photos you would use kUTTypeImage:
Code:
myImagePickerController.mediaTypes =
[NSArray arrayWithObject:(NSString *)kUTTypeMovie];
Keep in mind that you should check if the device supports video recording before setting the sourceType, as setting it to a movie type on a device that does not support video recording will cause all sorts of havoc. You do that by looking at the available source types:
Code:
NSArray *sourceTypes =
[UIImagePickerController availableMediaTypesForSourceType:myImagePickerController.sourceType];
if (![sourceTypes containsObject:(NSString *)kUTTypeMovie ]){
// no movie type supported...add code to handle that here.
}
Quote:
Originally Posted by NewiPhoneDeveloper
Hello,
Now my question is (and sorry if it's a stupid one): How and what mediaType do I assign, so UIImagePickerController directly launches with the video camera?
|