2012-09-29 47 views
1

是否有可能使用FBFriendPickerViewController获取朋友用户图片? 我想:FBFriendPickerViewController来保存朋友图片

FBFriendPickerViewController *friendPicker = [[FBFriendPickerViewController alloc] init]; 
friendPicker.fieldsForRequest = [[NSSet alloc] initWithObjects:@"picture", nil]; 
[friendPicker loadData]; 
[friendPicker presentModallyFromViewController:self 
             animated:YES 
             handler:^(FBViewController *sender, BOOL donePressed) { 
              if (donePressed) { 
UIImage *pic = friend[@"picture"]; 
... 

但在friend[@"picture"]nil

回答

0

解决方案

NSURL *profilePictureURL = [NSURL URLWithString:friend[@"picture"][@"data"][@"url"]]; 
                   NSURLRequest *profilePictureURLRequest = [NSURLRequest requestWithURL:profilePictureURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0f]; // 

                   [NSURLConnection sendAsynchronousRequest:profilePictureURLRequest 
                            queue:[NSOperationQueue mainQueue] 
                         completionHandler:^(NSURLResponse* response, NSData* receivedData, NSError* error) 
                   { 
                    UIimage *userpic = [UIImage imageWithData:receivedData]; 
                   }]; 
3

试试这个代码在你的块内,在这里我得到它的工作。

if (donePressed) { 
    for (id<FBGraphUser> user in self.friendPickerController.selection) { 
     UIImage *pic = user[@"picture"]; 
     NSLog(@"%@",pic);            
    } 
} 
+0

日志显示,它的NSDictionary与URL里面,这样我就可以从那里 – Shmidt

+0

抓取图像当然,没有注意到这是一本字典,好抓。 – alexandresoli

相关问题