是否可以使用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"];
...
但nil
中有friend[@"picture"]
。
答案 0 :(得分:3)
在你的区块内尝试这个代码,我在这里工作了。
if (donePressed) {
for (id<FBGraphUser> user in self.friendPickerController.selection) {
UIImage *pic = user[@"picture"];
NSLog(@"%@",pic);
}
}
答案 1 :(得分: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];
}];