如何在UITableView中获取特定行的高度 [英] How can I get the height of a specific row in my UITableView

查看:146
本文介绍了如何在UITableView中获取特定行的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 UITableView 中,我使用委托方法为不同的行设置了不同的高度: tableView:heightForRowAtIndexPath:

In my UITableView i've set different heights for different rows using the delegate method: tableView:heightForRowAtIndexPath:

现在给出 NSIndexPath ,我想得到我之前为特定行分配的高度。

Now given a NSIndexPath, I would like to get the height I've previously assigned for a specific row.

推荐答案

你可以使用这个

CGRect frame = [tableView rectForRowAtIndexPath:indexPath];
NSLog(@"row height : %f", frame.size.height);

使用 frame.size.height 你可以得到特定行的高度

Using frame.size.height you can get height of particular row

Swift 3

let frame = tableView.rectForRow(at: indexPath)
print(frame.size.height)

这篇关于如何在UITableView中获取特定行的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆