【发布时间】:2015-07-16 15:46:51
【问题描述】:
我遇到了 UITableViewCell 中的垂直对齐问题。
我正在使用 正确的细节 UITableViewCell,其中 detailTextLabel 包含多行文本。 通过将行数设置为零,我设法让 detailTextLabel 显示所有文本。然而,这会导致(左)文本标签在左上角而不是 UITableViewCell 的中心对齐。
有没有办法使用其中 detailTextLabel 包含多行(在本例中为 2)并让主文本标签垂直居中的 TableViewCell?
【问题讨论】:
-
如果您的用例不同,您应该创建自己的原型单元
-
您是否尝试设置标签的垂直对齐方式? cell.textLabel.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter
-
@DejanSkledar 我不相信
contentVerticalAlignment是 UITextLabel 的属性? -
我的错,我把它和 textField 混在一起了。
-
我应该只改变 textLabel 的高度。
标签: ios xcode uitableview alignment detailtextlabel