I'm fairly new to iOS dev and very new to storyboards. I'm trying to create a basic form using a UITableView with static cells and a "grouped" style.
I'm hoping to make only one storyboard and use it for both iPhone and iPad, not sure if this is recommended but I don't really have and design elements that are specific to either device so there'd be a lot of repetition if I maintain a separate storyboard for both device families.
So I drag a label onto the left hand side of my table cell and a text input onto the right then I use auto-layout and setup some constraints: - Label has a leading space to superview of 30 - TextField has a trailing space to superview of 30 - Horizontal spacing constraint between the label and textfield - Fixed width constraint on label
It works great on iPhone however on iPad the label and textfield extend beyond the edges of the table cell. This is because iPad has wider margins (wider than the 30pt constraints I used) on the left and right side of the table cells.
It's obvious why it doesn't work. I guess my question is, that this is a common scenario and I suspect there's a simple solution. Interested to hear recommendations. Is there a way to constrain the label and textfield to the edges of the cell rather than the edges of the table? If not should I:
- Replicate the storyboards for iPhone and iPad
- Use a form library like QuickDialog
- Add and arrange the label and textfields programatically
- Any other suggestions?
Here's a screenshot showing the auto-layout constraints:
And this is how the layout behaves on iPad: