- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想不出执行某些任务的最有效和“优雅”的方法。问题定义是:我想显示几个 View ,其中之一是带有相机胶卷源的 ImagePicker。
层次结构类似于:主视图 ---> 选择器 ---> 图像处理 View 当用户点击“后退按钮”时,UI 必须允许向后显示。
我尝试了几种选择:
1.
a) MAIN VIEW 以模态方式呈现选择器 View 。b) 在 didFinishPickingMediaWithInfo 委托(delegate)方法中关闭选择器模态视图,然后使用图像处理 View 调用 presentModalViewController。
示例代码:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage* pickedImage = [info valueForKey:UIImagePickerControllerEditedImage];
LastViewController* vc = [[LastViewController alloc] init];
vc.mainImage = pickedImage;
[self dismissModalViewControllerAnimated:NO];
[self presentModalViewController:vc animated:NO];
}
问题是,它不起作用,因为 Controller 在关闭另一个模态后无法显示下一个模态(上一个模态不会立即消失,MAIN 不会立即激活,也无法显示新模态)。
2。主视图以模态方式呈现图像处理 View ,但紧接着图像处理 View 以模态方式呈现选择器 View ,等待完成,关闭选择器,用户可以看到带有库中图像的图像处理 View 。
示例代码:
在主视图 Controller 的一些 Action 中:
ImageProcessViewController *vc = [[ImageProcessViewController alloc] initWithNibName:@"ImageProcessViewController" bundle:nil];
vc.delegate = self;
vc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:vc animated:NO];
[vc release];
在 ImageProcessViewController 中:
- (void)viewDidLoad {
[super viewDidLoad];
//some UI init here
if(self.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
ipc.delegate = self;
ipc.allowsEditing = YES;
[self presentModalViewController:ipc animated:NO];
[ipc release];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage* pickedImage = [info valueForKey:UIImagePickerControllerEditedImage];
self.mainImage = pickedImage;
[self dismissModalViewControllerAnimated:NO];
}
问题是,我无法在 viewDidLoad 方法中调用 presentModalViewController,因为它不起作用(我猜这在 View Controller 生命周期中还为时过早)。我也在 viewDidAppear 中尝试过,但在那种情况下,我必须设置一些 ivar 标志,只显示一次选择器 View ,并且在图像选择器 View 之前短时间显示空图像处理 View ,我不想要这个。
3。我试图弄清楚如何使用 Navigation Controller 来执行此操作,因为 UIImagePickerController 正在使用他的导航 Controller ,但这是私有(private)结构,文档说程序员不能这样做。
请给我一些建议,因为我现在真的迷路了
最佳答案
在您的主视图 Controller 中,使用 viewDidAppear:animated: - 这将在模式转换完成时调用。您可以从那里安全地开始另一个模式转换。
关于iphone - ImagePicker 中的 View 层次问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5042103/
最小码: File _file; Future _pickImage() async { final image = await ImagePicker.pickImage(source: Ima
我正在从事一个涉及视频捕捉的项目。我本质上想以编程方式捕获视频,这意味着我不希望任何相机或任何东西弹出;我只想在按下两个按钮之间录制视频。 我定义了图像选择器并在按下按钮时开始视频捕获: if (UI
我在 Swift 中使用 ImagePickerSheetController。我的代码看起来像这样 controller.addAction(ImagePickerAction(title: NS
我正在尝试在 SwiftUI 中创建一个图像选择器,如下 this tutorial .基本上,这个想法是当用户点击屏幕上的灰色矩形时,会出现一个图像选择器。当他们选择一个图像时,它被导入到灰色矩形中
我正在用它来返回视频文件,但是我得到了.jpg Future getVideo() async { var video = await ImagePicker.pickVideo(
按照以下链接添加 ImagePicker https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/depend
按照以下链接添加 ImagePicker https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/depend
我正在使用正在点击“加载文件”的 WKWebView。 WKWebView 为我打开 UIImagePickerView,在此期间我需要知道 - 选择了什么图像。 最佳答案 为我工作。 overrid
我正在寻找一个自定义控件,我可以将其放入具有 UIImagePicker 功能的 UIViewController 中。 (显示缩略图,启用 multiselect 等)但显示来自“服务器”的图像(给
当我当前尝试更改属性时,收到一条错误消息,指出大小是“仅获取属性”。有人知道解决这个问题的方法吗? 最佳答案 您可以尝试以下操作(我还没有运行它,很确定它有效..) let imagePickerVi
正如标题所示,我正在尝试在您选择照片后提供更改照片的可能性。目前,如果用户不取消选择前一张照片,则无法选择另一张照片,因此我对选择多张照片不感兴趣,而只是每次触摸时都能移动光标。 fileprivat
我苦苦寻找,但找不到解决这个问题的合适方法。我正在为 iPad2 构建一个应用程序。我们公司会将 iPad2 提供给销售人员,但他们会使用配置实用程序禁用相机应用程序。 我的应用程序使用 UIImag
我正在尝试使用以下 Ionic 插件,以便我可以打开图库并选择多个图像:https://ionicframework.com/docs/native/image-picker#installation
当用户选择“选择现有”时, View 会在顶部加载并首先显示最旧的图片。但是,我希望它在底部加载以显示最近拍摄的图像。我知道这是可能的,因为这是 Apple 的 iMessage 和 Facebook
我的 iPad 应用程序仅支持横向。我已经以模态方式呈现了 ABNewPersonViewController (在导航 Controller 中作为苹果文档的建议)并且处于景观中。 现在, 当我尝试
我对应用程序的要求是在整个应用程序中显示状态栏。在某些 View Controller 上我调用图像选择器。单击 buttonImage,当当前 View Controller 消失并且相机出现时,状
我一直在努力让视频正常工作,但遇到了一个与编译器有关的奇怪问题。我的代码看起来像这样。 UIImagePickerController * imagePicker = [[UIImagePicker
我的应用程序中有一个图像选择器,可以打开用户相册 (iOS),以便他们可以选择图像。我正在使用 xamarin 跨平台,所以我有一个导致这段代码的依赖服务。之后我得到了所有正确的代码,但问题是图像选择
我正在构建一个小应用程序,允许用户选择要附加到帖子的图像。用户选择添加图像(具有点击手势识别器)并显示 iOS 照片库。然后,用户选择图像,所选图像应替换默认的相机图像。从库中选择图像时出现以下错误:
如标题所示,当使用设备的照片库从 WKWebview 选择图像时,imagePicker 似乎没有注册照片已被选中已选中。 下面是它发生的图片 这里没有太多代码。它只是简单地设置一个 WKWebvie
我是一名优秀的程序员,十分优秀!