After iOS 7, Cell becomes so simple as plateau


Let’s look at the implementation of the class comment effect

After iOS 7, Cell becomes so simple as plateau

Due scene

I believe we have used UITableView, more or less will encounter cell needs to be high scene. UITableView inherits from UIScrollView and needs to set cell’s height in advance in the following two ways

Method 1. - (CGFloat) tableView: (UITableView *), tableView, heightForRowAtIndexPath: (NSIndexPath *), indexPath{} method 2., self.tableView.rowHeight = 0.f;

IOS 7 before setting high, you need to calculate the height of each cell in method 1, very troublesome,
iOS 7 after setting high, just set the following two key points, you can easily reality

critical code

1. set the estimatedRowHeight attribute of the tableView and estimate the height of the cell without the need to set the height in the tableView proxy

Self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.estimatedRowHeight = 70.f; self.tableView.allowsSelection = NO;

2. in the custom cell, the AutoLayer property setting needs to be increased. The height of the Label is greater than or equal to the attribute, as shown in figure

The After iOS 7, Cell becomes so simple as plateau
setting is greater than or equal to attributes

Complete code can be downloaded here, there are problems can be communicated in the comment area ha!