IPhone - 在UITableViewCell中移动detailTextLabel

时间:2009-09-02 14:44:35

标签: iphone cocoa-touch uikit uitableview uilabel

我正在构建一个UITableViewCell。我正在为我的表格视图单元格使用UITableViewCellStyleSubtitle样式。在单元格的textLabel中,我有可能需要换行的数据。因此,为了适应,我想向下移动detailTextLabel,以便detailTextLabel中的文本不包含包装文本。我正在尝试以下方法:

CGPoint tempPoint = tableViewCell.detailTextLabel.center;
tempPoint.y += 100;
tableViewCell.detailTextLabel.center = tempPoint;

我尝试过与标签框架类似的方法,但我无法让它移动。当我在前后记录中心点的y时,我总是看到它从0开始,之后它只有100。我在NSLog中使用%f标志来查看值。这一切都发生在函数中:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

任何帮助都会很棒。

1 个答案:

答案 0 :(得分:2)

我将UITableViewCell子类化并实现了 - (void)layoutSubviews方法。我用那种方法移动了标签。

相关问题