Application から複数の画像をアップロードしようとしています。
画像の配列があり、このコードを使用してすべての画像をアップロードしています。しかし、アップロード中に画像が多い場合、UI がブロックされます。バックグラウンドでアップロードを開始する方法を提案するか、別の方法を提案してください..
HUD = [[MBProgressHUD alloc] initWithView:self.view];
HUD.labelText = @"Uploading Images";
[self.view addSubview:HUD];
[HUD show:YES];
NSMutableArray *aryFetchedImages = [self fetchPhotosForAlbum];
for (int i = 0; i < aryFetchedImages.count ; i++) {
NSLog(@"img%d",i);
[params setObject:@" " forKey:@"message"];
[params setObject:UIImageJPEGRepresentation([aryFetchedImages objectAtIndex:i], 50.0f) forKey:@"picture"];
[FBRequestConnection startWithGraphPath:@"me/photos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (error)
{
//showing an alert for failure
#ifdef DEBUG
NSLog(@"Unable to share the photo please try later - Fail %@",error);
#endif
}
else
{
//showing an alert for success
#ifdef DEBUG
NSLog(@"Photo %@ uploaded on Facebook Successfully",UIImageJPEGRepresentation([aryFetchedImages objectAtIndex:i], 50.0f));
#endif
}
}];
}
[HUD show:NO];
[HUD removeFromSuperview];