Objective-C - 找出textLabel在UITableViewCell中的位置

时间:2011-09-11 12:44:01

标签: objective-c cocoa-touch uitableview

我想找出textLabel的{​​{1}}属性的默认x位置。最简单的方法是什么?

干杯,

彼得

2 个答案:

答案 0 :(得分:2)

cell.textLabel.frame.origin.x

为您提供textLabel相对于其包含视图的位置。

答案 1 :(得分:1)

您可以通过获取其frame.origin.x属性来获取UILabel的x位置。因此,对于单元格的标签,您将使用cell.textLabel.frame.origin.x

请注意,您对textLabel中的默认detailLabelUITableViewCell所做的工作并不多。您最好的选择通常是create custom cell并使用它。