1)친구
하는 것은 페이스 북 SDK의 최신 버전으로 FBFriendPickerViewController의 변화가 있었다 보여 FBFriendPickerViewController을 얻을하는 방법. 그것은 당신에게 당신의 페이스 북 친구 모두와 함께 친구 선택기를 제공하는 데 사용되었지만 이제는 당신의 앱을 사용한 친구들 만 보여줍니다. 편리하지만 사용자 전체 친구 중에서 선택할 필요가있는 응용 프로그램의 기능이 있습니다.
Senario = 친구 선택기를 사용하여 친구를 선택하려고 시도하고 선택 후 선택한 친구의 사용자 세부 정보를 제공하는보기 컨트롤러가 표시됩니다. 즉, 다음 VC에서 "id"를 사용하여 친구 정보를 검색 할 수 있도록 선택된 친구 "id"가 다음보기 컨트롤러에 유지되어야합니다 (이는 friendPicker.selection 속성으로 인해 FBFriendPickerViewController를 편리하게 만듭니다).
Question = 친구 선택 도구에서 전체 Facebook 친구의 목록을 얻을 수있는 방법을 아는 사람이 있습니까?
2)
대안 = 또 다른 가능한 해결책은 테이블 뷰를 생성하고 북에서 JSON 함께 테이블을 로딩하여이 방법 일 수있다. 거기서부터 cellForRowAtIndexPath에 친구 데이터를로드 할 수 있습니다.
NSString *accessToken = [FBSession activeSession].accessTokenData.accessToken;
NSString *surl = @"https://graph.facebook.com/me/friends?access_token=%@&fields=picture,name,id";
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:surl, accessToken]];
NSURLRequest * request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:^(NSURLResponse *r, NSData *d, NSError *e) {
if (e==nil) {
NSDictionary *jsonData = [NSJSONSerialization JSONObjectWithData:d options:NSJSONReadingAllowFragments error:nil];
friends = [NSMutableArray arrayWithArray:jsonData[@"data"]];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
idx = indexPath.row;
NSSortDescriptor *sort=[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];
[friends sortUsingDescriptors:[NSArray arrayWithObject:sort]];
f = friends[idx];
// Configure the cell...
//cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background_lightgrey.png"]];
cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"facebook_blue.png"]];
cell.layer.borderColor = [[UIColor blackColor] CGColor];
//cell.layer.borderWidth = 1;
cell.layer.cornerRadius = 10;
cell.imageView.layer.borderColor = [[UIColor whiteColor] CGColor];
cell.imageView.layer.borderWidth = 1;
cell.imageView.image = [UIImage imageNamed:@"fbDefaultPic.png"];
cell.textLabel.text = f[@"name"];
UIImage *theImage = f[@"image"];
if (theImage==nil) {
cell.imageView.layer.borderColor = [[UIColor whiteColor] CGColor];
cell.imageView.layer.borderWidth = 1;
NSString *url = f[@"picture"][@"data"][@"url"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
imgData = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
UIImage *img = [UIImage imageWithData:imgData];
dispatch_async(dispatch_get_main_queue(), ^{
cell.imageView.image = img;
//NSMutableDictionary *newFriend = [NSMutableDictionary dictionaryWithDictionary:f];
//friends [idx] = newFriend;
//newFriend [@"image"] = img;
});
});
}
else {
cell.imageView.image = theImage;
}
return cell;
}
대체 = 문제이 방법으로 선택한 친구의 "아이디"를 유지하기 란 매우 어렵습니다. (테이블 뷰가 FBFriendPickerViewController와 같은 .selection 속성을 가졌지 만 슈퍼 트 리뷰가 도움이된다면 ...).
질문 = 다른 사람이 Facebook 친구의 tableView를 만들 수있는 방법을 도와 줄 수 있고 "id"를 추출 할 수있어 싱글 톤 변수에 저장하고 다른 사람의 변수에서 사용할 수 있습니다. 컨트롤러보기?
문제 = 모든 친구 표시) 1,하지만 친구의 "ID"를 얻을 수 있습니다 -
는 요약 위해 -.
문제 2) = 모든 친구가 나타나지만 친구의 "id"를 얻을 수 없습니다.
어떤 해결책이 있습니까? 이것이 지금부터는 경우라면, 나는 아마도 Facebook SDK를 덤프 할 것이다. 이것은 나를위한 주요 유스 케이스였다. – KVISH
Nah가 아직 아무 것도 찾지 못했습니다. 친구를 직접 쿼리해야합니다. –
그게 무슨 뜻인지 설명해 주시겠습니까? 설명서에 링크가 있습니까? – KVISH