【问题标题】:UITableViewCell conflicting height constraintUITableViewCell 冲突高度约束
【发布时间】:2015-06-16 23:23:21
【问题描述】:

我有一个自定义表格视图单元格,我让自动布局管理它的高度。

tableView.estimatedRowHeight = 44
tableView.rowHeight = UITableViewAutomaticDimension

在 tableview 单元格内,我有一个容器子视图:

contentView.addSubview(calendarEventContainerView)

我添加的所有内容都在calendarEventContainerView 中,我希望子视图至少为 120pts,但同时,我希望它被固定到 contentView(以便它拉伸内容查看)。我唯一可以让它正确显示的时候是当我收到一个错误说我的代码不能同时满足约束时。这是我的约束代码:

calendarEventContainerView.autoPinEdgeToSuperviewEdge(.Top, withInset: CalendarEventLayout.verticalInset)
calendarEventContainerView.autoPinEdgeToSuperviewEdge(.Leading, withInset: CalendarEventLayout.horizontalInset)
calendarEventContainerView.autoPinEdgeToSuperviewEdge(.Trailing, withInset: CalendarEventLayout.horizontalInset)
calendarEventContainerView.autoPinEdgeToSuperviewEdge(.Bottom)
calendarEventContainerView.autoSetDimension(.Height, toSize: 120, relation: NSLayoutRelation.Equal)

任何想法我做错了什么?

【问题讨论】:

    标签: ios swift uitableview autolayout


    【解决方案1】:

    出于未知的原因,将约束的优先级设置为 999 似乎可以解决自动调整 UITableViewCells 的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-20
      • 1970-01-01
      • 2019-05-07
      • 2011-01-31
      • 1970-01-01
      • 1970-01-01
      • 2021-12-11
      • 1970-01-01
      相关资源
      最近更新 更多