Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Facebook多张图片上传_Ios_Facebook - Fatal编程技术网

Ios Facebook多张图片上传

Ios Facebook多张图片上传,ios,facebook,Ios,Facebook,我正在尝试从我的应用程序上载多个图像 我会有一个图像数组,我用这个代码上传所有的图像。但在上传时,如果图像更多,我的UI就会被阻止。因此,请建议我如何开始在后台上传或建议我一个替代的方式 HUD = [[MBProgressHUD alloc] initWithView:self.view]; HUD.labelText = @"Uploading Images"; [self.view addSubview:HUD]; [HUD show:YES]; NSMutableArray *ary

我正在尝试从我的应用程序上载多个图像

我会有一个图像数组,我用这个代码上传所有的图像。但在上传时,如果图像更多,我的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];
HUD=[[MBProgressHUD alloc]initWithView:self.view];
HUD.labelText=@“上传图像”;
[self.view addSubview:HUD];
[抬头显示器显示:是];
NSMutableArray*AryFetcheImage=[self-FetchPhotoForalBum];
for(int i=0;i
我正在对代码进行一些修改,请尝试一下,并让我知道

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++) {

    [self postImgWithMessage:[aryFetchedImages objectAtIndex:i];
    }


    [HUD show:NO];
    [HUD removeFromSuperview];


    //my code to be added

    -(void)postImgWithMessage:(UIImage *)image 
    {
        NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory , NSUserDomainMask, YES);
        NSString *filePath =[[paths1 objectAtIndex:0] stringByAppendingPathComponent:@"image.png"];
        NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
        [imageData writeToFile:filePath atomically:YES];    
        if (filePath == nil) return;
        NSURL *url = [NSURL URLWithString:@"https://graph.facebook.com/me/photos"];
        ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
        [request addFile:filePath forKey:@"file"];
        [request setPostValue:[userDefaults stringForKey:KToken] forKey:@"access_token"];
        [request setDidFinishSelector:@selector(sendToPhotosFinished:)];
        [request setDelegate:self];
        [request startAsynchronous];

    }

    - (void)sendToPhotosFinished:(ASIHTTPRequest *)request
    {
        //NSLog(@"photo sent");

    }
HUD=[[MBProgressHUD alloc]initWithView:self.view];
HUD.labelText=@“上传图像”;
[self.view addSubview:HUD];
[抬头显示器显示:是];
NSMutableArray*AryFetcheImage=[self-FetchPhotoForalBum];
for(int i=0;i
通过调度队列,您可以异步或同步地执行与调用方相关的任意代码块。您可以使用调度队列执行几乎所有在单独线程上执行的任务。调度队列的优点是使用更简单,执行这些任务的效率更高e任务比相应的线程代码多