I'm on macOS 10.13.6, Xcode 10.1, and am working on an iPhone (only) app.
I've a settings scene (in a tab bar controller) that's rather simple: contains a table view with one prototype cell.
This cell contains a label on the left and a switch on the right.
I want the label to auto-resize according to it's content. Therefore I set both, the "Row Height" and the "Estimate" settings of the table view to "Automatic" and the Lines attribute of the label to 0 (zero) and the Line Break attribute to "Word Wrap". (Additionally did this in code, too, when the cell get's created in cellForRowAt:indexPath.)
I added four constraints to the label:
- trailing, top and bottom space should be fix in relation to the content view
- the trailing constraint is a fixed value in relation to the leading of the switch.
The switch has two contraints (and the one above in common with the label):
- it should be centered vertically
- its trailing space whould be fixed in regards to the content view.
See screenshot: https://www.dropbox.com/s/qdbmewqnn0gaklz/ConstraintsProblemRedacted.png?dl=0
This is what happens: https://www.dropbox.com/s/v37bxsrdtgf6j3b/ConstraintsProblemOn3SimulatorsRedacted.jpg?dl=0
So, the autoresizing of the table view cells works and the auto-multiline of the label works, too, that's not the problem.
However, I have two questions:
- What circumstances can cause the trailing space contraints of the switch cause to not be obeyed?
- How can a single prototype cell behave in different ways when it's instanciated two times? Sometimes the switch is too far right, sometimes not.
Obviously, the label text sometimes (but not always, depending on screen size?!) get too long and pushes the switch to the right.
Any help here much appreciated!