0

我目前正在制作一个 Facebook iOS 应用程序,并且在该应用程序中我试图让用户 Facebook 墙并将其放在 UITable 视图中。

到目前为止我有:

[facebook requestWithGraphPath:@"me/home" andDelegate:self];

加载视图时调用此方法。

Facebook 中的 Did Receive Response,我想用帖子填充表格视图,但这是我遇到问题的地方。我到处寻找答案,并阅读了苹果和 Facebook 文档,但它们对我的情况没有帮助。另外,如果有人发布视频或图像,我将如何在 TableView 中处理?任何帮助将不胜感激。

谢谢,维林德博拉

4

2 回答 2

1

您需要获取响应并将其放入 NSArray。然后在你的 UITableViewDelegate 方法中加载单元格:

-(void)request:(FBRequest *)request didLoad:(id)result {
   // take my result and put it into an array, usually it's an NSDictionary
    NSArray *friendsFBData = [result objectForKey:@"data"];
    NSMutableArray *friendIds = [NSMutableArray arrayWithCapacity:friendsFBData.count];
    for (int x = 0; x < friendsFBData.count; x++) {
        [friendIds addObject:[((NSDictionary*)[friendsFBData objectAtIndex:x]) objectForKey:@"id"]];
    }

   // don't forget to call loadData for your tableView
   [self reloadData];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // Grab data from array
    NSString *myName = [myArray objectAtIndex:indexPath.row];
    [myLabel setText:myName];
}
于 2012-05-06T01:04:39.853 回答
0

如果该调用是官方的 facebook API 调用,我假设它是异步的,因此期望传入的委托来处理更新。

您的对象是否将此设置称为某种 FaceBookDelegate,然后需要一个名为 facebookDidReceiveResponse 的方法或其他方法?这可能是下一步......检索通过委托方法返回的数据。

于 2012-05-06T00:25:47.140 回答