iPad:访问相册时发生崩溃

发布于 2024-10-24 07:47:49 字数 836 浏览 3 评论 0原文

我正在尝试使用以下代码访问相册。它在我的 iPhone 或 iPad 4.0 以下版本上运行良好。

  • (void)浏览照片库:(id)发件人 {
NSArray *types = [UIImagePickerController availableMediaTypesForSourceType:
    UIImagePickerControllerSourceTypePhotoLibrary];

if ([types containsObject:(id)kUTTypeMovie])
{

    UIImagePickerController *imgPickerController = [[[UIImagePickerController alloc] init] autorelease];
    imgPickerController.delegate = self;
    imgPickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imgPickerController.mediaTypes = [NSArray arrayWithObject:(id)kUTTypeMovie];

    [self presentModalViewController:imgPickerController animated:YES];             
}

}

如果相册中至少有一个视频,则相同的代码会在 iPad 2 4.3 版本中崩溃,如果相册中没有任何视频,则相同的代码会启动到相册。有人可以建议这可能是什么原因吗?

I am trying to access Photo Album using the following code. It works fine on my iPhone or iPad less than 4.0 versions.

  • (void)BrowsePhotoLibrary:(id)sender
    {
NSArray *types = [UIImagePickerController availableMediaTypesForSourceType:
    UIImagePickerControllerSourceTypePhotoLibrary];

if ([types containsObject:(id)kUTTypeMovie])
{

    UIImagePickerController *imgPickerController = [[[UIImagePickerController alloc] init] autorelease];
    imgPickerController.delegate = self;
    imgPickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    imgPickerController.mediaTypes = [NSArray arrayWithObject:(id)kUTTypeMovie];

    [self presentModalViewController:imgPickerController animated:YES];             
}

}

The same code crashes in iPad 2, 4.3 version if there is atleast one video available in Photo Albums, if Photo album doesn't have any video, then the same code launches to Photo Album. Could someone advise what could be the reason here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

隔岸观火 2024-10-31 07:47:49

我通过更改 imgPickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; 修复了它

I fixed it by changing imgPickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文