I'm having a problem with a UIImageView inside of a UITableViewCell when using autolayout. Specifically I'd like to have the image separated from the edges (20pt) , with a strict size(50pt) and so I have defined this: imageview to top = leading to edgeview = 20 height = width = 50
What i find is that the imageview completely ignores its constraints(sorry about the scary smiley, it's what google images gave me). Naturally my desired layout would have more content, but regardless of whether that content is present the effect is the same.
The setup for the project is as follows: Make a single view app Add a table view, connect the data source and write boilerplate to make at least one cell create a tableviewcell with nib, add an imageview to the tableviewcell constraints to top/leading (10 works, with a height of 20) set an image in the imageview so you can see it at runtime
I feel like that should be sufficient, but it seems not to be working, am I missing something silly? For comparison this same setup causes no problem without a tableview, the imageview behaves just the way expected
It turns out I had missed one step that kept Anna's version working, I had connected the UIImageView with a property named imageView (overwriting the UITableViewCell default property), apparently the constraints in the superclass were stronger than whatever I was adding.
I couldn't quite get this to work myself, but I think you'll get it if you try some of the things in here:
Using Auto Layout in UITableView for dynamic cell layouts & variable row heights
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With