Note that there are some explanatory texts on larger screens.

plurals
  1. POAuto layout with custom UITableViewCell
    text
    copied!<p>How do I get the contents of a custom UITableViewCell to shift and resize using Auto Layout?</p> <p>To make the issue more clear, I've assigned the <code>contentView</code> of my custom cell to have a light gray background color. To reduce this to the smallest problem possible, my custom cell has only one <code>UIImageView</code> named <code>ratingImageView</code> that shows some number of yellow stars; three such cells can be seen in the image below.</p> <p><img src="https://i.stack.imgur.com/GI0KN.png" alt="Table view with custom cells and auto layout"></p> <p>My <code>ratingImageView</code> has only 4 constraints; (1) width =81, (2) height =40, (3) align center Y to superview, and (4) trailing space to superview =20. I would have expected the trailing space to superview constraint to force the image view to the left when the standard delete button appears on swipe to delete. It does not, however, as can be seen in the image below.</p> <p><img src="https://i.stack.imgur.com/thREt.png" alt="Custom cell content not moving with auto layout"></p> <p>I've tried many different combinations of constraints and cannot make the <code>ratingImageView</code> shift as I would expect.</p> <p>I encountered this problem by working through a good <a href="http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1" rel="nofollow noreferrer">introductory Storyboard tutorial</a>. I had no problem making this work using good old struts and springs, but I decided to try it with Auto Layout and have had no luck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload