【问题标题】:Text doesn't appear in UITableViewCell (iOS7/Storyboard)文本没有出现在 UITableViewCell (iOS7/Storyboard)
【发布时间】:2013-11-17 01:10:35
【问题描述】:

我正在尝试在我的UITableView 中显示一些内容。这就是我在 Storyboard 中的做法:

在我的代码中,我创建了一个解析器并将其传递给我的TableViewController。然后:

- (void)parserDidEndDocument:(NSXMLParser *)parser 
{
    [myTVController.tableView reloadData];
}

在我的控制器中:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"RSSLinksCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    RSSObject *obj = (RSSObject *)[links objectAtIndex:indexPath.row];
    cell.textLabel.text = obj.link;

    return cell;
}

但我的牢房一直是空的。更奇怪的是,我也在 iOS6 上试过,效果很好。我尝试更改单元格的backgroundColor,它也有效。 在日志中,我还尝试查看我的 obj.link 文本是否为空或 null 但不是。 所以......我真的不知道该怎么办。任何帮助将不胜感激。

【问题讨论】:

  • 你能检查一下 tableview 的数据源和委托是否设置为那个类吗?
  • @EnricoSusatyo 是的,因为我使用的是 UITableViewController,它是自动完成的,我又检查了一遍。
  • 我的想法已经不多了,但是如果你使用[tableView dequeueReusableCellWithIdentifier:CellIdentifier] 方法呢?而不是forIndexPath?
  • 当你说你已经在 iOS 6 上尝试过 - 当你从一个平台转移到另一个平台时,你有什么变化?只是切换模拟器?或者您有单独的 iOS 6 项目/XIB?
  • 只是切换模拟器。我也试过@EnricoSusatyo,但没有解决问题。

标签: objective-c xcode uitableview ios7 storyboard


【解决方案1】:

你试过了吗:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"RSSLinksCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"RSSLinksCell"];
    }

    RSSObject *obj = (RSSObject *)[links objectAtIndex:indexPath.row];
    cell.textLabel.text = obj.link;

    return cell;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-21
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多