Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 571 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Autolayout is ignored in Custom UITableViewCell

#1
Despite having set constraints to all elements, including the vertical ones needed for the cell to calculate its height, auto-layout seems to be ignored: all cells are squeezed.

Here's a screenshot of the result and of the constraints in the storyboard:

[![enter image description here][1]][1]

[![enter image description here][2]][2]

In the VC that holds the tableView, here's the code in **viewDidLoad:**

tableView.estimatedRowHeight = 120.0
tableView.rowHeight = UITableViewAutomaticDimension

Commenting out the second line gives cells with a height of 120.0 but Autolayout is ignored as well.

----------

## Update ##

To simplify the interface, I've left a single label with, as constraints:

- Leading space to superview
- Top space to superview
- Fixed width and height (100 & 100)
- Bottom space to container margin to make sure that the cell has all vertical constraints to determine its height

And with this simplified interface, auto-layout is still not taken into account, which hints me that the problem did not come from badly set constraints.

In the Size Inspector, the row height is set on 120 and Custom is checked. The cell has the right custom class, the cell reuse identifier is correct.


[1]:

[2]:
Reply

#2
Auto-layout was ignored because both the prototype cell AND the UIView of the cell had been given the custom cell class in IB.

Setting the UIView back to UIView class solved the problem.

[![just to be über clear][1]][1]

[1]:
Reply

#3
I think the problem is that you are implementing :

func tableView(_ tableView: UITableView, heightForRowAt indexPath:
IndexPath) -> CGFloat {

return x
}

You need to remove this function inorder for the tableview to calculate its automatic height for cells.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through