问题
I have a prototype tableview cell, with a custom view inside of the tableview cell. The view controller that contains the tableview will only be displayed in landscape mode. The goal is for the UIView that is inside of the tableview cell to resize it's width based on the form factor. So for example there might be a 20pt spacing on the left and right and then the uiview resizes it's width to fill the rest of the space. I'm hoping to do this with storyboard and autolayout.
In 3.5 inch form factor it looks like this (this is what it should look like in 4 inch mode as well)
In 4 inch form factor it looks like this (width didn't auto resize)
I understand that the 'auto layout' here is legal, since the horizontal space is >20 on the 4 inch form factor as well. The heart of the question though is... how do I get a subview to autoresize it's width when the width of the screen changes using storyboard/autolayout/constraints?
回答1:
All you need are following four constraints to autosize your cell view for 3.5 and 4 inches screens.
Xcode 4.6 Interface Builder
has a bug where at times it does not properly apply constraints when switching ViewController size between 3.5" and 4" at design time. However, it works just fine when opened in the 3.5" and 4" simulators.
来源:https://stackoverflow.com/questions/18862476/resize-view-with-auto-layout-between-3-5-and-4-inch-form-factor