小编Arn*_*nka的帖子

UITableViewCell 中的几个多行标签,故事板中的自动布局 xcode 6.3.2

我在 tableviewcell 内的 UILabels 中截断文本有问题。到目前为止,我已阅读并测试了以下链接中的解决方案(以及许多其他类似链接):

但如果我使用“标准”顶部、前导、尾部和底部自动布局约束设置单元格,我似乎无法让它在第一次加载时工作。但是,如果我取消选中超级视图项的“相对边距”并使用例如等于:默认值,我可以

如果我旋转设备或再次向下和向上滚动,它适用于这两种情况。

标签与自定义单元上的出口相连,并在原型单元中垂直放置;它们每个都有三个超级视图约束,标签之间有一个“标准”的垂直距离。拥抱优先级在最上面的标签上设置得更高,以消除 IB 中的警告,即使这对结果无关紧要。

相关代码:

TableViewController.m

- (void)viewDidLoad {
    [super viewDidLoad];
    if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1) {
        self.tableView.estimatedRowHeight = self.tableView.rowHeight;
        self.tableView.rowHeight = UITableViewAutomaticDimension; }
    }


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TableViewCellIB *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    [cell adjustSizeToMatchWidth:CGRectGetWidth(self.tableView.frame)];

    cell.titleLabel.text = @"Veeeeeeeery looooooooooooooooong Tiiiiitle";
    cell.messageLabel.text = @"Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

1
推荐指数
1
解决办法
4385
查看次数

标签 统计

ios ×1

objective-c ×1

uitableview ×1