UIImagePickerController媒体类型kUTTypeMovie运行时异常

UIImagePickerController媒体类型kUTTypeMovie运行时异常

问题描述:

我正在开发iPhone应用程序,我只需要查看设备照片库中显示的所有视频.我正在使用以下代码

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];

我已经导入MobileCoreServices框架并将其添加到我的项目中.

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

它在运行于iOS 4.3的iPhone 3GS上运行良好,但是当我在运行iOS 4.2.1的iPod Touch上运行时,它显示了运行时异常

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'

我尝试用字符串替换术语kUTTypeMovie.

I have tried replacing the term kUTTypeMovie with the string.

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

同样,它在具有上述iOS版本的iPhone 3GS上也能很好地工作,但在iPod Touch上再次崩溃.

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

我意识到,定义上述字符串常量的UICoreTypes.h在装有iOS 3及更高版本的设备中受支持.

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

可能是什么问题?我关注了与此类问题相关的其他帖子,例如 kUTTypeMovie无法正常工作

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.

我认为您的问题出在UIImagePickerController的源类型上,您是否将其设置为UIImagePickerControllerSourceTypeSavedPhotosAlbum?看来您还没有,因此得到了no source available错误,是您使用的ipod touch带有摄像机可能没有...

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