4

写真ライブラリから複数の画像を選択するための画像ピッカーがあります。選択した写真のサイズが変更され、 のファイルに保存されますimagePickerController:didFinishPickingMediaWithInfo:。数秒かかります。

ビューにインジケーターを配置できますか? メソッドで使用しようとしaddSubview:indicatorViewました。imagePickerController:didFinishPickingMediaWithInfo:しかし、indicatorViewは表示されません。imagePickerView で却下されます。

4

1 に答える 1

3

ビュー階層の最上位に UIActivityIndi​​catorView を追加する必要があります。そうしないと、サイズ変更操作の後にコールバックを使用し、コールバックで UIImagePickerController を破棄しない限り、UIPickerViewController で破棄されます。

または、 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 に答える