iOS之estimatedHeightForRowAtIndex帕特h幸免程序EXC_BAD_ACCESS

在您的连串中把estimatedHeightForRowAtIndexPath方法写达成以下,重临2个估摸高度(随便估,小编提议依然依据寻常思路来写,大约中度是多少就赶回多少),那样就不会报EXC_BAD_ACCESS错误了.

注意:estimatedHeightForRowAtIndexPath方法既是底下那些方法.

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath;

知识举办:

  • 在未曾完成estimatedHeightForRowAtIndexPath主意时,那七个措施(numberOfRowsInSection,heightForRowAtIndexPath,cellForRowAtIndexPath)的调用顺序如下:
    • 1.先调用numberOfRowsInSection
    • 2.再调用heightForRowAtIndexPath
    • 3.再调用cellForRowAtIndexPath
  • 实现了estimatedHeightForRowAtIndexPath方法后,调用顺序是那般的

    • 1.numberOfRowsInSection
    • 2.estimatedHeightForRowAtIndexPath
    • 3.cellForRowAtIndexPath
    • 4.heightForRowAtIndexPath
  • 接下去本人来证实以下现身EXC_BAD_ACCESS错误的由来:

    • 当您没用完毕**estimatedHeightForRowAtIndexPath方法,在heightForRowAtIndexPath措施赢得cell的时候,会形成3个死循环,那就是numberOfRowsInSectionheightForRowAtIndexPath方法不断互调,最终程序崩溃.

相关文章