Iphone 如何向UIImagePickerController添加指示器
我有一个图像选择器从照片库中拾取多个图像。拾取的照片将调整大小并保存到Iphone 如何向UIImagePickerController添加指示器,iphone,ios,uiimagepickercontroller,uiactivityindicatorview,Iphone,Ios,Uiimagepickercontroller,Uiactivityindicatorview,我有一个图像选择器从照片库中拾取多个图像。拾取的照片将调整大小并保存到imagePickerController:didFinishPickingMediaWithInfo:中的文件中。这需要几秒钟 我能在视图上加个指示器吗? 我已尝试在imagePickerController:didFinishPickingMediaWithInfo:方法中使用addSubview:indicatorView。但indicatorView没有出现。它将被imagePickerView解除。您应该在视图层次结
imagePickerController:didFinishPickingMediaWithInfo:
中的文件中。这需要几秒钟
我能在视图上加个指示器吗?
我已尝试在
imagePickerController:didFinishPickingMediaWithInfo:
方法中使用addSubview:indicatorView
。但indicatorView没有出现。它将被imagePickerView解除。您应该在视图层次结构的顶部添加UIActivityIndicatorView,否则它将被UIPickerViewController解除,除非您在调整大小操作后使用回调并在回调中解除UIImagePickerController
或者你可以使用一个进度HUD,比如
希望这有帮助()
我们进行了一次简短的聊天,并通过以下方式解决了问题:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
UIView *primaryImage = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,460)];
primaryImage.backgroundColor = [UIColor redColor];
primaryImage.alpha =0.9;
UIView *secondaryImage = [[UIView alloc] initWithFrame:CGRectMake(0,0,70,70)];
secondaryImage.center = CGPointMake(160, 240);
secondaryImage.backgroundColor = [UIColor blackColor];
secondaryImage.alpha = 0.9;
secondaryImage.layer.cornerRadius = 12;
[primaryImage addSubview:secondaryImage];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
indicator.center = CGPointMake(35, 35);
[indicator setHidesWhenStopped:NO];
[secondaryImage addSubview:indicator];
[indicator startAnimating];
[indicator release];
[secondaryImage release];
[picker.view addSubview:primaryImage];
[primaryImage release];
});
// Put here the code to resize the image
dispatch_async(dispatch_get_main_queue(), ^{
// Dismiss the picker controller
});
});
是的,我把它放在视图层次结构的顶部,但直到取消动画期间它才显示出来。这就是我所说的“它将被UIPickerViewController忽略”。对于“在视图层次结构的顶部”,我指的是在UIWindow中。无论如何,当您创建UIPickerController并使用ivar控制它时,您可以尝试添加UIIndicatorView。您的意思是添加到窗口?让我试试,还是不行。是的,我已经创建了一个指示器并先将其隐藏,但一旦我将“隐藏”设置为“否”,它就不起作用了。指示器是UIActivityIndicatorView实例吗?如果是,您应该在停止时使用hides,然后在调用startAnimating方法时它将可见。实际上,我将指示符视图放在另一个UIView的侧面。例如[anotherUIView addSubview:indicator];并尝试控制另一个UI视图以隐藏和显示。