1

是否有可能让朋友使用用户图片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"];
...

但是里面nilfriend[@"picture"]

4

2 回答 2

3

在你的块内试试这个代码,我让它工作了。

if (donePressed) {
   for (id<FBGraphUser> user in self.friendPickerController.selection) {
        UIImage *pic = user[@"picture"];
        NSLog(@"%@",pic);                                              
   }
}
于 2012-10-02T16:25:54.667 回答
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];
                                                                }];
于 2012-10-02T17:17:45.110 回答