【发布时间】:2012-09-21 18:32:29
【问题描述】:
我在自定义 UITableViewCell 中有一个自定义 UIButton。我想根据按钮 titleLabel 的可变文本内容在自定义表格单元格中设置 UIButton 的高度。
我尝试了以下方法来计算高度
[NSString sizeWithFont:constrainedToSize:lineBreakMode:];
但我无法根据 titleLabel 成功更改按钮高度。
此外,由于此按钮是自定义 UITableViewCell 的一部分,因此我还需要根据自定义 UIButton 的高度更改单元格的高度。
在实现UITableView的delegate和datasource方法的ViewController中,我尝试在下面的方法中确定高度
- (CGFloat) tableView: (UITableView *) tableView
heightForRowAtIndexPath:(NSIndexPath *)indexPath
但没有成功。
解决这个问题的最佳解决方案或方法是什么?
【问题讨论】:
-
在这里查看我的答案 - stackoverflow.com/questions/12506313/…
标签: iphone ios uitableview uibutton uilabel