Ios 5 prototype cells and VoiceOver issue

I had a problem trying to load a prototype cell when Voiceover is turned on. Application crashes and I get errors

Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:] Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' 

This only happens when VoiceOver is turned on, otherwise the application works fine. Any help?

+6
source share
1 answer

I'm not sure if I got it by accident, but it worked for me. In 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; } 

I believe that iOS caches cells without accessibility properties if VoiceOver is disabled for performance reasons. Thus, the default identifier you are using may be associated with a cached cell that does not have these properties. When VoiceOver is turned on and iOS tries to remove these cells, it does not find any properties and gaps there. By having different IDs, you force iOS to cache new cells when VO is enabled.

Again, this is just an assumption of what I am doing , but the fact is that I am not getting this problem when I deactivate cells in this way. However, if you delete them as I mentioned, you will have to keep an eye on the error that may occur:

If you are decalizing the cells whose identifiers are set in the .xib file or in the storyboard, as in the image below, you will need to set up another Prototype cell with the VO reuse identifier. Reuse Identifier set in Interface Builder

0
source

Source: https://habr.com/ru/post/902357/


All Articles