0

I am trying to build a simple user form which is adaptive to the screen. Right now I am able to show some text fields vertically. I want to group two fields together so that they will appear next to each other horizontally in the landscape mode.

How can I do that for iOS 8?

jscs
  • 63,694
  • 13
  • 151
  • 195
Himanshu Yadav
  • 13,315
  • 46
  • 162
  • 291
  • 2
    The cheapest solution would be to use Size classes and make two different layouts for smaller and bigger screens (better solution would involve complex usage of constraints) - https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LayoutandAppearance.html – Lachezar Aug 10 '15 at 18:35
  • 1
    Requests for links to tutorials are not allowed on Stack Overflow, so I've edited your question to ask directly for a solution to your problem. – jscs Aug 10 '15 at 18:36
  • @Lucho Do you have any example for cheap solution? – Himanshu Yadav Aug 10 '15 at 18:51

2 Answers2

0
  1. For different size classes you can have different autolayout setup(constraints) . You will have to select landscape mode from attribute inspector. Then align your text fields, add constraint. It will behave the way you want. Checkout the last 5-6 minutes of Stanford CS193p lecture no 8. Easily you will learn how to do it.

  2. An alternate solution is using collective view which on slight tweaking to FlowLayout will behave the way you need. Hope it helped. I Would prefer to go with this if have not watched that lecture

iOS_Dev
  • 26
  • 6
0

Why don't you consider using a CollectionViewController to handle this for you? You can specify that when the screenWidth is greater than a certain number, that two cells are displayed per row rather than only one. If you spend a little time working with the appearance, it will appear as though it is simply a list of fields that do exactly what you've asked for above. You can make it look exactly like your proposed photo above and then move to 2 cells per row when you're in landscape mode. If this sounds like something you want to try but aren't sure how to go about the implementation, let me know and I'll update my answer.

Bret Smith
  • 88
  • 10