Skip to content

Commit 1d8c459

Browse files
Tyler FoxTyler Fox
authored andcommitted
Update workaround for row insertion bug
This has been fixed as of iOS 7.1, adding comments to this effect.
1 parent 1ae779a commit 1d8c459

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

TableViewCellWithAutoLayout/TableViewController/RJTableViewController.m

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ @interface RJTableViewController ()
3939
// { NSString *reuseIdentifier : UITableViewCell *offscreenCell, ... }
4040
@property (strong, nonatomic) NSMutableDictionary *offscreenCells;
4141

42+
// For iOS 7.0.x compatibility ONLY (this bug is fixed in iOS 7.1):
4243
// This property is used to work around the constraint exception that is thrown if the
4344
// estimated row height for an inserted row is greater than the actual height for that row.
4445
// See: https://github.com/caoimghgin/TableViewCellWithAutoLayout/issues/6
@@ -206,15 +207,16 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
206207

207208
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
208209
{
209-
if (self.isInsertingRow) {
210-
// A constraint exception will be thrown if the estimated row height for an inserted row is greater
211-
// than the actual height for that row. In order to work around this, we return the actual height
212-
// for the the row when inserting into the table view.
213-
// See: https://github.com/caoimghgin/TableViewCellWithAutoLayout/issues/6
214-
return [self tableView:tableView heightForRowAtIndexPath:indexPath];
215-
} else {
216-
return UITableViewAutomaticDimension;
217-
}
210+
// NOTE for iOS 7.0.x ONLY, this bug has been fixed by Apple as of iOS 7.1:
211+
// A constraint exception will be thrown if the estimated row height for an inserted row is greater
212+
// than the actual height for that row. In order to work around this, we need to return the actual
213+
// height for the the row when inserting into the table view - uncomment the below 3 lines of code.
214+
// See: https://github.com/caoimghgin/TableViewCellWithAutoLayout/issues/6
215+
// if (self.isInsertingRow) {
216+
// return [self tableView:tableView heightForRowAtIndexPath:indexPath];
217+
// }
218+
219+
return UITableViewAutomaticDimension;
218220
}
219221

220222
@end

0 commit comments

Comments
 (0)