4

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

我可以在视图上放置一个指示器吗?我曾尝试addSubview:indicatorViewimagePickerController:didFinishPickingMediaWithInfo:方法中使用。但是没有出现indicatorView 。它被 imagePickerView 解散。

4

1 回答 1

3

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

或者你可以使用像SVProgressHUD这样的进度 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

    });
});
于 2012-05-13T14:24:04.447 回答