I have a problem with AutoLayout on iOS (6.x), which I don't know the answer about.
I have a UITableViewCell with UILabel and UITextField, for example:
+------------------+ | label textField | +------------------+
I want to use AutoLayout to build them, but there is a caveat. UILabel should be 100 points in portrait mode and 175 points in landscape mode.
those. in visual format language it will look as follows
Portrait: |-[label(100)]-[textField]-| Landscape: |-[label(175)]-[textField]-|
Thus, the text box will occupy the rest of the cell view.
Of course, I could solve this by overwriting willRotateToInterfaceOrientation:duration: and finding out which cells are currently being displayed, then calling updateConstraints on them, so I can update the width of the label depending on the orientation, but that doesn't seem to be the way to go. First of all, an adventure in spinning animation seems difficult or impossible. Secondly, my feeling tells me that I can solve it with priorities and inequalities. I would add something like [label(>=100,<=175)] for the label, but then I need to do something else, because otherwise the label will always be up to a certain size (100 or 175).
I thought I fixed it: I set the cover priority of the content of the label to 200, set a limit on the text field, that the width should be at least 152, and then it does what I want, if only I, for example, allow the editing mode of the table view , because then the text field cannot be more than 152 points (not enough space). Entering this arbitrary “152” is also not like going.
Anyone have any suggestions on how I can fix this?