【问题标题】:Blank cells when running on ios 9.1 or 9.0 simulator, works fine on 8.4 simulator在 ios 9.1 或 9.0 模拟器上运行时的空白单元格,在 8.4 模拟器上运行良好
【发布时间】:2015-11-21 18:52:27
【问题描述】:

在 ios 模拟器 9.1 或 9.0 上运行我的应用程序时,单元格为空白且 xcode 未显示错误。在 8.4 模拟器上运行良好。代码没有变化。

我已经尝试了以下

  1. 删除情节提要中的自定义单元格并重新创建它。没用
  2. 更改了标识符和文件名。没用
  3. 从项目中删除了自定义单元 .h 文件,然后将其添加回来。没用
  4. tableView 可见后执行reloadData。没用。
  5. 断开连接,然后重新连接情节提要中的 tableView 委托和数据源。没用。
  6. 在我的自定义单元格中使用了默认的 customCell.textLabel.text = [_nameArray objectAtIndex:indexPath.section]; 和 imageView customCell.imageView.image = [_profileImageArray objectAtIndex:indexPath.section]; 属性。有效,但这无济于事,因为我想使用我的自定义对象。
  7. 硬编码 customName、customTime 和 customImage。 customCell.customName.text =@"hi";customCell.customImage.image = [UIImage imageNamed:@"commentButton.png"];。没用
  8. 我在数据源方法中添加了断点并执行了所有断点。
  9. 我使用 NSLog 来查看我的 customCell 是否为 nil。我从日志<messagePreviewCell: 0x7fcdf8dd3860; ...> 收到以下回复。
  10. 在 cellForRowAtIndexPath 中设置值之前,我 NSLog 了 nameLabel,它记录了情节提要中设置的内容。
  11. 我在我的代码/情节提要中搜索隐藏命令,没有设置为隐藏。

选中“使用大小类”复选框,我已将大小设置为“wCompact hAny”。

在 viewcontroller.m 中找到的 cellForRowAtIndexPath 的代码

    static NSString *simpleTableIdentifier = @"messagePreviewCell";

    messagePreviewCell *customCell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    customCell.customName.text = [_nameArray objectAtIndex:indexPath.section];
    customCell.customTime.text = [_timeArray objectAtIndex:indexPath.section];
    customCell.customDescription.text = [_messageArray objectAtIndex:indexPath.section];

    NSString *className = [[[_profileImageArray objectAtIndex:indexPath.section] class] description];

    if ([className isEqualToString:@"UIImage"]) {
        customCell.customImage.image = [_profileImageArray objectAtIndex:indexPath.section];
    }

    return customCell;

我的代码运行良好...请帮忙,谢谢!

【问题讨论】:

  • 如果您对标签文本进行硬编码,单元格仍为空?例如:customCell.customName.text = @"HELLOOO";
  • 检查您的数据源//_nameArray 或 _timeArray.. 对标签进行硬编码
  • 您是否将故事板中的 customName/customType/customDescription 标签连接(创建 IBOutlets)到您的代码?
  • 此时要做的一件好事可能是在一些数据源方法中添加断点。然后检查: 1. 他们是否被叫到。 2. 你要出列的单元格是 nil。 3. 你的nameArraytimeArraymessageArray 是零吗? 4. 单元格上的标签是否为零。 5. 单元格上的任何内容是否通过 opacity 或 hidden 属性隐藏。
  • 你在使用尺码等级吗?

标签: ios objective-c xcode uitableview


【解决方案1】:

如果您只为一个设备系列进行开发,请取消选中情节提要的文件检查器中的“使用大小类”。

在这里找到我的答案(附加信息)! UITableView Empty with iOS 9 beta 5 update

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    • 2017-10-28
    • 1970-01-01
    相关资源
    最近更新 更多