我在 facebook 图形 api 上工作。而且我已经获得了使用我的应用程序的用户的 ID。我可以显示用户的 id 和我想要做什么,它在我的 tableview 的每个单元格中显示一个 FBProfilePictureView 给好用户。
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (!error) {}
NSString* fql =
@"SELECT uid FROM user WHERE is_app_user=true AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
[FBRequestConnection startWithGraphPath:@"/fql"
parameters:@{ @"q" : fql}
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
FBRequest *fql = [FBRequest requestForGraphPath:@"fql"];
[fql.parameters setObject:@"SELECT uid,name,is_app_user FROM user WHERE is_app_user AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())" forKey:@"q"];
[fql startWithCompletionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
if (result) {
NSArray *arrayRsult = [result objectForKey:@"data"];
NSMutableArray *ids = (NSMutableArray *) [arrayRsult valueForKey:@"uid"];
NSMutableArray *names = (NSMutableArray *) [arrayRsult valueForKey:@"name"];
recentFriends = [[NSMutableArray alloc] init];
idFriends = [[NSMutableArray alloc] init];
for (NSDictionary *c in ids)
{
[idFriends addObject:c];
}
arrayLength = [recentFriends count];
NSLog(@"ids are : %@ ",idFriends);
NSLog(@"there are %i", arrayLength);
我已经完成了,首先,使用以下代码在每个单元格中显示我的 facebook 个人资料图片:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
FBProfilePictureView *prof = [[FBProfilePictureView alloc]initWithFrame:CGRectMake(5, 5, 30, 30)];
[[FBRequest requestForMe] startWithCompletionHandler:
^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *user, NSError *error) {
if (!error) {
prof.profileID = [user objectForKey:@"id"];
}
}];
[cell addSubview:prof];
}
我不将自定义单元格和笔尖用于自定义单元格。我不知道如何为这个表创建一个数组。我试过这段代码 cell.imageView.image = [idFriends objectAtIndex:indexPath.row];
(idFriends 在 .h 文件中声明为 __block NSMutableArray )谢谢你的帮助!