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];
}
本文介绍了一种在UITableView中动态计算UITableViewCell高度的方法。通过在cell中定义类函数并返回高度值,可以实现在-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath函数中的调用。
271

被折叠的 条评论
为什么被折叠?



