【问题标题】:ios 5 prototype cells and VoiceOver issueios 5 原型单元和旁白问题
【发布时间】:2012-01-06 01:34:39
【问题描述】:

我在 Voiceover 开启时尝试加载原型单元格时遇到问题。应用程序崩溃,我收到错误

Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:]

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'

这仅在 VoiceOver 开启时发生,否则应用程序运行正常。有什么帮助吗?

【问题讨论】:

  • 如果其他人对此问题有疑问,我向苹果提交了有关此问题的错误。
  • 我也有同样的问题!我今天开始向我的应用程序添加可访问性提示和内容。这真的很糟糕。您能否在此处添加雷达 ID,以便我/我们可以复制该错误。我在 5.1 beta 2 中仍然遇到这个错误!
  • @ChristianBeer 在 Open Radar 中发现了您的错误并复制了它。 (rdar://10763569) 谢谢。
  • 这真的很糟糕,有人找到解决方法吗?
  • 在 iOS 6.0.1 中启用 VoiceOver 时仍然遇到同样的问题,非常令人气愤。

标签: iphone ios ipad ios5


【解决方案1】:

我不确定这是否是偶然的,但这对我来说很有效。在UITableViewDataSource:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    [...]

    UITableViewCell *standardCell;
    if (UIAccessibilityIsVoiceOverRunning()) {
        standardCell = [tableView dequeueReusableCellWithIdentifier:@"VO Cell"];
    } else {
        standardCell = [tableView dequeueReusableCellWithIdentifier:@"Regular Cell"];
    }

    //Configure the cell
    [...]

    return standardCell;

}

如果出于性能原因关闭了 VoiceOver,我认为 iOS 会缓存没有可访问性属性的单元格。所以你使用的默认 Identifier 可能与没有这些属性的缓存 Cell 有关。当 VoiceOver 开启且 iOS 尝试将这些 Cell 出列时,它找不到其中的属性并中断。通过使用不同的标识符,您可以强制 iOS 在 VO 开启时缓存新的单元格。

再次,这只是我所做的假设,但情况是,当我以这种方式使 Cells 出队时,我不会遇到这个问题。但是,如果您确实按照我提到的方式将它们出列,则必须注意可能出现的错误:

如果您要将标识符设置在 .xib 文件或情节提要中的单元出列,如下图所示,则必须使用 VO 重用标识符设置另一个原型单元。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-05
    • 2012-08-20
    • 1970-01-01
    • 2020-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多