UIImagePicker 和叠加层
在我的应用程序中,使用 uiimagepicker 选取图像后,它会通过 Web 服务进行处理。网络处理需要一秒钟,所以我想创建一个带有活动指示器视图的灰色覆盖层。
我的问题是 UIImagePickerView 视图似乎停留在所有内容之上,直到处理完成。
我尝试在加载覆盖层或处理甚至开始之前使用 [myPicker DismissModalViewControllerAnimated:YES];
,但视图仍在屏幕上。之后,我的叠加层按如下方式加载,
ovController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:[NSBundle mainBundle]];
CGFloat yaxis = self.navigationController.navigationBar.frame.size.height;
CGFloat width = self.view.frame.size.width;
CGFloat height = self.view.frame.size.height;
CGRect frame = CGRectMake(0, yaxis, width, height);
ovController.view.frame = frame;
ovController.view.backgroundColor = [UIColor grayColor];
ovController.view.alpha = 0.7;
[self.view insertSubview:ovController.view aboveSubview:self.view];
在我关闭 myPicker 之前,我也尝试使用 [[myPickercameraOverlayView] insertSubview:ovController.view];
,但无济于事。
需要明确的是,我尝试在 UIImagePicker 消失之后但在 Web 处理开始之前将“正在加载”叠加层显示在屏幕上。
任何意见将不胜感激。谢谢
In my app, after an image is picked with uiimagepicker, it is processed via a webservice. The web processing takes a second, so I'd like to create an grayed out overlay with an activity indicator view.
My problem is that the UIImagePickerView view seems to stay on top of everything until the processing is finished.
I have tried using [myPicker dismissModalViewControllerAnimated:YES];
before the overlay is loaded or the processing even starts, but the view is still on screen. After that, my overlay is loaded as followed
ovController = [[OverlayViewController alloc] initWithNibName:@"OverlayViewController" bundle:[NSBundle mainBundle]];
CGFloat yaxis = self.navigationController.navigationBar.frame.size.height;
CGFloat width = self.view.frame.size.width;
CGFloat height = self.view.frame.size.height;
CGRect frame = CGRectMake(0, yaxis, width, height);
ovController.view.frame = frame;
ovController.view.backgroundColor = [UIColor grayColor];
ovController.view.alpha = 0.7;
[self.view insertSubview:ovController.view aboveSubview:self.view];
I have also tried using [[myPicker cameraOverlayView] insertSubview:ovController.view];
before I dismiss myPicker, but to no avail.
To be clear, I am trying bring the "loading" overlay on the screen after the UIImagePicker goes away, but before the web processing starts.
Any input will be appreciated. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您正在主线程上进行上传,这会锁定视图以使其无法更新。您可以尝试在单独的线程上进行上传,以便主线程可以关闭图像选择器并显示叠加层。
It sounds like you are doing the upload on the main thread which is locking the view from being updated. You might try doing the upload on a sperate thread so that the main thread can dismiss the image picker and display the overlay.