IOS estimatedHeightForRowAtIndexPath avoids program EXC_BAD_ACCESS,

Source: Internet
Author: User

IOS estimatedHeightForRowAtIndexPath avoids program EXC_BAD_ACCESS,

Write the estimatedHeightForRowAtIndexPath method in your project to implement the following implementation, and return an estimated height (I suggest you write it according to the normal idea, and then return the approximate height ), in this way, the EXC_BAD_ACCESS error will not be reported.

Note:: EstimatedHeightForRowAtIndexPath is the following method.

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath;
Knowledge Development:
  • In the absence of implementationEstimatedHeightForRowAtIndexPathMethod, the three methods (numberOfRowsInSection,heightForRowAtIndexPath,cellForRowAtIndexPath:
    • 1. Call numberOfRowsInSection first
    • 2. Call heightForRowAtIndexPath again.
    • 3. Call cellForRowAtIndexPath again.
  • ImplementedEstimatedHeightForRowAtIndexPathThe call sequence is as follows:

    • 1. numberOfRowsInSection
    • 2. estimatedHeightForRowAtIndexPath
    • 3. cellForRowAtIndexPath
    • 4. heightForRowAtIndexPath
  • Next, let me explain the cause of the EXC_BAD_ACCESS error:

    • When you are useless** EstimatedHeightForRowAtIndexPathMethod, inHeightForRowAtIndexPathWhen the cell method is used to obtain the cell, an endless loop is formed, that isNumberOfRowsInSectionAndHeightForRowAtIndexPathMethods are constantly intertuned, and finally the program crashes.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.