Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

previewing autolayout with different sizes and language styles

I've started learning the new Auto Layout stuff in XCode on iOS. Auto Layout is actually quite neat, but it appears to be a pain to test. I seem to remember on the Mac side there was a way you could Preview an interface and drag it to different sizes to test if controls lined up properly. Is there anything like this for iOS or some tool to facilitate testing your AutoLayout views? Additionally, something to switch to Right to Left would be useful too. I just want to test all my constraints and make sure they're perfect.

like image 705
Larry Avatar asked Mar 29 '13 20:03

Larry


3 Answers

To view a preview of what Auto Layout will do under different conditions, do the following in Xcode 5:

  1. Open up a storyboard.
  2. Open the assistant editor (as many as you want).
  3. In the assistant editor, tap the 4th button (the one that says Manual/Automatic/etc).
  4. Choose "Preview".
  5. You can now use the controls on the bottom right to customize:
    • the iOS version (6 or 7)
    • device rotation (portrait or landscape)
    • device screen size (3.5" or 4")

To simulate a right-to-left language, according to the WWDC 2012 Auto Layout by Example (Session 232) video:

  • Set the following arguments: (using a method such as this)
    • AppleTextDirection YES
    • NSForceRightToLeftWritingDirection YES

More arguments that can help with Auto Layout can be found here.

like image 118
Senseful Avatar answered Nov 20 '22 19:11

Senseful


If you have localized strings, you can go to the Xcode Product menu then pick Scheme ---> Edit Scheme. In the top section on the right (Arguments Passed On Launch), click the + button and then type in: -NSDoubleLocalizedStrings YES and make sure the check box next to it is checked. This will double all your localized strings to simulate a language like German that tends to have long words.

like image 30
rdelmar Avatar answered Nov 20 '22 19:11

rdelmar


Thanks to Apple we have the live preview in the new XCode 5.

like image 1
Marius Popescu Avatar answered Nov 20 '22 18:11

Marius Popescu