UIImagePickerController mediatype kUTTypeMovie run

2019-09-08 19:53发布

问题:

I am developing an iPhone App where I need to only view all the videos present in the Photos Library of a device. I am using the following code

UIImagePickerController picker = [[UIImagePickerController alloc] init];
picker.mediaTypes = [NSArray arrayWithObject:(NSString*)kUTTypeMovie];

I have imported and added the MobileCoreServices framework to my project.

It works great on the iPhone 3GS, running on iOS 4.3, but when I run it on my iPod Touch, having iOS 4.2.1, it shows a runtime exception

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'No available types for source 2'

I have tried replacing the term kUTTypeMovie with the string.

picker.mediaTypes = [NSArray arrayWithObject:@"public.movie"]; 

Again, it works great on the iPhone 3GS with the aforesaid iOS version, but again crashes on the iPod Touch.

I realized that UICoreTypes.h, which defines the above said string constant, is supported in devices with iOS 3 and above.

what could be the possible problem? I have followed other posts related to such problems, like kUTTypeMovie not working

but, this only tells us to include the above included framework. Please help.

回答1:

I think your problem is in the source type of the UIImagePickerController, have you set it to UIImagePickerControllerSourceTypeSavedPhotosAlbum? It seems that you havent and therefore you get the no source available error, is the ipod touch you using have a video camera probably doesnt...