我正在尝试从我的 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];