本文介绍了将UIActivityIndi​​cator添加到模式视图(ELCimagepicker)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将ELCimagepicker(https://github.com/Fingertips/ELCImagePickerController)添加到我的项目中,并且效果很好,允许用户为幻灯片选择多个图像.但是,当您单击保存"时,根据添加的照片数量可能会有很长的延迟.

I've added the ELCimagepicker (https://github.com/Fingertips/ELCImagePickerController) to my project and it works perfectly, allowing the user to select multiple images for a slideshow. But when you click 'Save', there can be a lengthy delay depending on how many photos were added.

我一直在尝试在用户单击保存"时添加UIActivityIndi​​cator,但是由于显示了模式视图而遇到了麻烦.我可以从ELCimagepicker呈现的活动(ELCImagePickerController)中调用一个方法,该活动由处理图像选择器呈现的活动来执行.但是,每当我尝试添加到视图时,都不会显示它,因为模式位于活动指示器的顶部.

I've been trying to add a UIActivityIndicator when the user clicks 'Save', but having trouble due to the modal view that is presented. I can call a method from the activity that ELCimagepicker presents (ELCImagePickerController) and this gets actioned by the activity handling the presenting of the image picker. But whenever I try to add to the view, it isn't shown as the modal is on top of the activity indicator.

我尝试过使用BringSubviewToFront,我尝试过使用[[self parentViewController] addSubView]将代码直接添加到imagepicker方法文件中,但是没有运气.

I've tried using bringSubviewToFront, I've tried adding the code directly to the imagepicker method file with [[self parentViewController] addSubView], but no luck.

这是我尝试过的最新代码:(该指标在.h文件中声明为UIActivityIndi​​cator * indicator)

Here's the latest code I tried: (indicator is declared in the .h file as UIActivityIndicator *indicator)

 indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicator.hidden=false;

[self.navigationController.view addSubview:self.indicator];
[self.navigationController.view bringSubviewToFront:self.indicator];

[indicator startAnimating];

if([delegate respondsToSelector:@selector(elcImagePickerController:showIndicator:)]) {
    [delegate performSelector:@selector(elcImagePickerController:showIndicator:) withObject:self withObject:@"test"];
}

有人在ELCimagepicker顶部添加UIActivityIndi​​cator或由另一个类处理的另一个模式视图是否成功?

Has anyone had any success with adding a UIActivityIndicator on top of the ELCimagepicker, or another modal view handled by another class?

我已经尝试了MBProgressHUD,但也无法正常工作-当我在ELCimagepicker类中使用它时,它将显示出来,但是在删除时崩溃:

I've tried MBProgressHUD but couldn't get that working quite right either - it would show up when I used it in the ELCimagepicker class, but crashed on removal with:

bool _WebTryThreadLock(bool), 0x42368e0: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...

任何帮助都是很棒的.

Any help would be fantastic.

谢谢.

推荐答案

我已经弄清了您的问题.您可以按照以下步骤进行操作.

I have figure out your problem. You can do this as below..

-(void)selectedAssets:(NSArray*)_assets {

UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
UIViewController * topView = [self.viewControllers objectAtIndex:[self.viewControllers count]-1];
activityIndicator.center = CGPointMake(topView.view.frame.size.width/2, topView.view.frame.size.height/2);
[activityIndicator setHidden:NO];
[topView.view addSubview:activityIndicator];
[topView.view bringSubviewToFront:activityIndicator];
[activityIndicator startAnimating];

[self performSelector:@selector(doProcess:) withObject:_assets afterDelay:2.1];

}

- (void) doProcess:(NSArray *)_assets {

NSMutableArray *returnArray = [[[NSMutableArray alloc] init] autorelease];

for(ALAsset *asset in _assets) {

    NSMutableDictionary *workingDictionary = [[NSMutableDictionary alloc] init];
    [workingDictionary setObject:[asset valueForProperty:ALAssetPropertyType] forKey:@"UIImagePickerControllerMediaType"];
    [workingDictionary setObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]] forKey:@"UIImagePickerControllerOriginalImage"];
    [workingDictionary setObject:[[asset valueForProperty:ALAssetPropertyURLs] valueForKey:[[[asset valueForProperty:ALAssetPropertyURLs] allKeys] objectAtIndex:0]] forKey:@"UIImagePickerControllerReferenceURL"];

    [returnArray addObject:workingDictionary];

    [workingDictionary release];
}

[self popToRootViewControllerAnimated:NO];
[[self parentViewController] dismissModalViewControllerAnimated:YES];

if([delegate respondsToSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:)]) {
    [delegate performSelector:@selector(elcImagePickerController:didFinishPickingMediaWithInfo:) withObject:self withObject:[NSArray arrayWithArray:returnArray]];
}

}

让我知道此答案是否对您有帮助...

Let me know if this answer help you ...

谢谢,MinuMaster

Thanks,MinuMaster

这篇关于将UIActivityIndi​​cator添加到模式视图(ELCimagepicker)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 01:46