Two uilabels on uitable with dynamic height

前端 未结 1 768
挽巷
挽巷 2021-01-27 21:26

I am trying to implement one English to Swedish learning app for Swift/IOS there I want to have two dynamic rows, data is coming from array and I tried my best to fix it out. I

相关标签:
1条回答
  • 2021-01-27 21:41

    You have to use UITableViewAutomaticDimension to manage the cell height as per the content. For that you have to set the constraint of your labels from all the sides, ie Click on the PIN and then uncheck the 'Constraint from margin' check box and for both of your labels add constraints from Top, bottom, Left and Right side.As it is required if you want to use UITableViewAutomaticDimension.

    Now in the ViewController in viewDidLoad method add this two line

    self.tableView.estimatedRowHeight = 44.0
    self.tableView.rowHeight = UITableViewAutomaticDimension
    

    and then you your labels will display full text.

    0 讨论(0)
提交回复
热议问题