UIImageView ignores AutoLayout constraints in UITableViewCell

I'm having a problem with a UIImageView inside a UITableViewCell when using autoplay. Specifically, I would like the image to be separated from the edges (20pt) with a strict size (50pt), and so I defined this: imageview to top = results in edgeview = 20 height = width = 50

enter image description here

What I find is that the image completely ignores its limitations (sorry for the scary emoji, this is what Google images gave me). Naturally, my desired layout would have more content, but whether or not that content is present, the effect is the same.

enter image description here

The setup for the project is as follows: Make one viewer app Add table view, connect datasource and write template to make at least one cell create tableviewcell with tip, add image to tableviewcell constraints for top / presenter (10 works with height 20) set image in image view so you can see it at runtime

I feel like this should be enough but it doesn't seem to work, am I missing something stupid? For comparison, this same setting does not cause problems without the tableview, the image should behave as expected

+3


source to share


3 answers


Turns out I missed one step that kept Anna's version out, I bound the UIImageView to the imageView property (overwriting the default UITableViewCell property), apparently the constraints in the superclass were stronger than anything else I added.
+12


source


I couldn't get this to work on my own, but I think you'll get it if you try some of these:



Using auto layout in a UITableView for dynamic cell layouts and row heights

+1


source


I think he is not ignoring him. Your setup is correct. You just need to stop painting the look of the image. Check it out in ImageView: Clip Subviews -> enabled. Also choose a good Fill Preview mode: Scale To Fill or Aspect.

0


source







All Articles