UITableVIew是先执行- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath函数计算整个UItableView内容高度,然后才执行
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath函数才创建UITableViewCell。
为了动态计算UitableViewCell的高度,在项目里我用在cell里定义了一个类函数,这样就可以在UITableView里调用,返回高度了。如我在项目中这样实现:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
IssueData *issueData = [self.items objectAtIndex:indexPath.row];
return [IssueViewCell cellHeightByData:issueData];
}