iOS VoiceOver crash (message sent to deallocated instance)

巧了我就是萌 提交于 2019-12-04 17:02:43

I had the same error. I removed the accessibility methods to get rid of tis error. We need to overwrite few accessibility methods to support reading order by voiceover in iOS 6

- (id)accessibilityElementAtIndex:(NSInteger)index
{
    return [[self accessibleElements] objectAtIndex:index];
}

- (NSInteger)indexOfAccessibilityElement:(id)element
{
    return [[self accessibleElements] indexOfObject:element];
}

If your code is crashing based on the above methods I feel. Try to remove those methods and check. One thing I observed is after removing the above methods Voiceover will not read the elements in order. It will read in some other(random) order.

Hope this will fix your crash.

We were able to find the problem by debugging on iOS 6 instead of 7.

In iOS 6,

AX ERROR: Could not find my mock parent, most likely I am stale.

was showing up in the console. That combined with the UITableViewCell error mentioned about, we dug through all of the table code in the sidebar.

We found that we were using reusable UITableViewCells as header views, and that was causing the zombie issue that we were seeing.

So bottom line, don't use UITableViewCells as UITableView header/footer view.

You can get this crash if you try to manually focus accessibility on to a UITableViewCell instead of a particular item inside the cell. If your requirement is to treat the tableCell as a whole as an accessibility element then in addition to specifying accessibility label and trait for the cell forget not to set isAccessibilityElement = YES for the cell. If isAccessibilityElement = YES then the iOS will not attempt to call [UITableTextAccessibilityElement setAccessibilityLabel:]method which causes the crash because it knows that tableCell itself is an accessibility element and will not try to examine what is inside the cell.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!