gpt4 book ai didi

iphone - 如何将指示器添加到 UIImagePickerController

转载 作者:可可西里 更新时间:2023-11-01 05:46:51 25 4
gpt4 key购买 nike

我有一个图像选取器可以从照片库中选取多张图像。选取的照片会调整大小并保存到 imagePickerController:didFinishPickingMediaWithInfo: 中的文件中。这需要几秒钟。

我可以在 View 上放置一个指示器吗?我尝试在 imagePickerController:didFinishPickingMediaWithInfo: 方法中使用 addSubview:indicatorView。但是 indicatorView 没有出现。它被 imagePickerView 关闭。

最佳答案

您应该在 View 层次结构的顶部添加 UIActivityIndi​​catorView,否则它会被 UIPickerViewController 关闭,除非您在调整大小操作后使用回调并在回调中关闭 UIImagePickerController。

或者您可以使用像 SVProgressHUD 这样的进度 HUD .

希望这有帮助 =)

我们做了一个小聊天 session 并以这种方式解决:

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

});
});

关于iphone - 如何将指示器添加到 UIImagePickerController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10572387/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com