【发布时间】:2018-01-01 13:22:02
【问题描述】:
在带有 Swift 3 的 Xcode 8 中,我使用了带有自动布局的自定义单元格。从 JSON 插入到单元格中的信息,所以我的代码如下所示:
//the method returning each cell of the list
public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cell = self.tableView.dequeueReusableCell(withIdentifier: "Feedcell", for: indexPath) as! FruitTableViewCell
//getting the hero for the specified position
let hero: List_Feed
hero = heroes[indexPath.row]
cell.labelAnswer.text = hero.answer
cell.labelQuestion.lineBreakMode = .byWordWrapping
cell.labelQuestion.text = hero.question
cell.labelQuestion.sizeToFit()
cell.labelAnswer.sizeToFit()
return cell
}
问题是每个单元格的 labelQuestion 高度相同,但文本大小和行大小不同。如何解决这个问题? :c
【问题讨论】:
-
您的标签高度因 cell 的高度而增加。尝试给背景颜色以找出增加了哪个标签高度
-
如果你今天的标签是一个内衬标签然后给它高度限制
-
@PrashantTukadiya 抱歉,没用,我附上了一张照片来提问
-
请查看答案
-
@PrashantTukadiya 我已经评论过了
标签: ios swift autolayout interface-builder