0

i am trying to make self sizing table view. the table view cell before editing is like this

enter image description here

there are 2 type of post in this table view cells. a post without image, and a post with an image. I want to make that second post 'Testting' which is only contains a text to shrink up using self sizing table view. I use this line of code in the viewDidLoad

  // to set the dynamic height of table view
    tableView.estimatedRowHeight = 100
    tableView.rowHeight = UITableViewAutomaticDimension

but the result it seems ugly. I think have used the right auto layout constraint before implementing self sizing table view. but i don't know what went wrong in here. it seems that it follows/depends the height of the image even though the image is not there

enter image description here

the autolayout contraints I used is like this enter image description here

username label constraints

enter image description here

avatar image constraints

enter image description here

post text label constraints

enter image description here

i suspect because it has 2 different constraint, one with image and the other doesn't have image. so how do i fix that ?

8
  • "I have used the right auto layout constraint before implementing self sizing table view" Obviously that's false. Remember, for this to work, the cell must size itself using constraints from the inside out. However, you don't say anything about what your constraints are, so your question is pointless.
    – matt
    Dec 23, 2017 at 2:42
  • "the table view cell before editing is like this " Nobody knows where your cell data comes from.
    – El Tomato
    Dec 23, 2017 at 2:58
  • @matt sorry, I have added the constraints now. Thanks :) Dec 23, 2017 at 3:07
  • Do you have heightForRowAt implemented? Also, are you getting messages about your layout in the Xcode console?? If not, what happens when you use the View Debugger? Does it report any ambiguity issues?
    – matt
    Dec 23, 2017 at 3:17
  • no i have not implemented heightForRowAt Dec 23, 2017 at 3:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.