UIImagePickerController mediatype kUTTypeMovie runtime exception

£可爱£侵袭症+ 提交于 2019-12-12 04:57:34

问题


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...



来源:https://stackoverflow.com/questions/9098918/uiimagepickercontroller-mediatype-kuttypemovie-runtime-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!