gpt4 book ai didi

iphone - ios 5 原型(prototype)单元格和 VoiceOver 问题

转载 作者:可可西里 更新时间:2023-11-01 04:03:45 24 4
gpt4 key购买 nike

我在尝试加载原型(prototype)单元格时遇到问题,而画外音打开。应用程序崩溃,我收到错误

Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:]

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

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

最佳答案

我不确定我是不是偶然做对了,但这对我来说很成功。在 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 会缓存没有辅助功能属性的单元格。因此,您使用的默认标识符可能与不具有这些属性的缓存单元有关。当 VoiceOver 打开并且 iOS 尝试使这些单元格出列时,它找不到其中的属性并中断。通过使用不同的标识符,您可以强制 iOS 在 VO 打开时缓存新的单元格。

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

如果您正在出列其标识符设置在 .xib 文件或 Storyboard 中的单元格,如下图所示,您将必须使用 VO 重用标识符设置另一个原型(prototype)单元格。 Reuse Identifier set in Interface Builder

关于iphone - ios 5 原型(prototype)单元格和 VoiceOver 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8264563/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com