在 iOS 5 中将 PresentViewController 与 UIImagePickerController 结合使用时,取消按钮显示为禁用状态

发布于 2024-12-29 10:50:57 字数 534 浏览 4 评论 0原文

当图像选择器控制器首先出现时,“取消”按钮显示为禁用状态并且不起作用,但是当我通过选择相册移动到下一个视图时,“取消”按钮变为启用状态并开始正常工作。

我应该怎样做才能保持“取消”按钮启用并始终有效?

imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
    NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:imgPicker.sourceType];
    imgPicker.mediaTypes = sourceTypes;
    [self  presentViewController:imgPicker animated:YES completion:Nil];
}

The Cancel button appears disabled and doesn't work when the image picker controller appears first, but as I move to the next view by selecting an album, the Cancel button becomes enabled and starts working fine.

What should I do to keep the Cancel button enabled and working all the time?

imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
{
    NSArray *sourceTypes = [UIImagePickerController availableMediaTypesForSourceType:imgPicker.sourceType];
    imgPicker.mediaTypes = sourceTypes;
    [self  presentViewController:imgPicker animated:YES completion:Nil];
}

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

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

发布评论

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

评论(1

装纯掩盖桑 2025-01-05 10:50:57
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)pick

你在UIImagePickerControllerDelegate中实现了这个功能吗?

更多参考

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)pick

Have you implement this function in UIImagePickerControllerDelegate?

More reference

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