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.