ios - 用 Facebook 相册填充 UITableView |操作系统

标签 ios uitableview facebook-graph-api

几周前我开始使用 IOS 和 Graph Api。我在用从 facebook 检索的专辑数据填充 UITableView 时遇到问题。我也将我的 appdelegete 设置为我的 uitabledatasource 和 uitabledelegate 在用户登录后发出以下请求:

NSString* fql = [NSString stringWithString:@"select object_id, cover_object_id, name, description from album where can_upload=1 and owner=me ()"];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"query"];
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self];
[theTable reloadData];

我在表格中实现了以下内容:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.resultData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];
    if (cell == nil) { 
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];
    }
    NSUInteger row = [indexPath row]; cell.textLabel.text = [[self.resultData objectAtIndex:row] valueForKey:@"name"];
    NSLog(@"the name %@", [[self.resultData objectAtIndex:row] valueForKey:@"name"]);
    return cell;
}

并像这样管理结果:

- (void)request:(FBRequest *)request didLoad:(id)result {
    if ([result isKindOfClass:[NSArray class]]) {
       resultData=result;
        [theTable reloadData];
}
NSLog(@"Result of API call: %@", result);
}

我得到了正确的查询结果,但表从未重新加载数据,因此它始终为空

最佳答案

首先,您需要在request:didLoad:中保留resultData(使用setter方法!)。

其次,您应该检查表是否根本不尝试重新加载数据,或者 TableView 数据源方法中是否出现问题。如果是前者,则 request:didLoad: 中的 theTable 实际上可能是 nil,因此 reloadData 调用没有影响。使用调试器进行检查。

如果情况并非如此,我们需要更多信息。使用调试器检查代码,检查每个 TableView 数据源方法是否被调用以及该流程中的处理出错的位置。

关于ios - 用 Facebook 相册填充 UITableView |操作系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8250115/

相关文章:

iOS 系统区域设置标识符为空

ios - UITableViewController 中的状态栏

node.js - 使用 facebook nodejs sdk 发布到群组 : OAuthException

node.js - 为什么我无法将其发布到我用户的 Facebook 墙上?

ios - Swift - 更改幻灯片的大小以删除 tableView 中的按钮

android - Facebook 与来自 Android 应用程序的元数据共享链接

ios - 我们可以使用 MDM 隐藏手机上安装的应用程序吗?

ios - 无法切换 UISwitch 的状态

ios - 无法使用 Cocoa Touch Framework 为项目创建存档

uitableview - 我的导航栏位于我的 TableView 中 - Swift