Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Chapter 4, layout shows differently on Simulator VS on nib

I followed the chapter 4 to create the simple application. There are a Segmented Control , Switches & a Button (named "Do Something"). In my nib, everything is located well. The Switches & the Button are below Segmented Control, and the Button is located at the same position of Switches, which covers the Switches

But when I run my app on simulator, the layout shows differently. The Switches & the "Do Something" Button are above the Segmented Control, and partly overlapped with each other. Why? Which attribute I missed to set??

Comments

  • I have the same problem. This is related to the various constraint defaults that IB assumes when you drag controls onto the view, I'm sure, but I don't know how to fix them yet.
  • Upon more experimentation, I couldn't get rid of the offending constraints. Every time I promoted a purple constraint to a user constraint and deleted it, it automatically recreated a new one. However, by setting the simulator to iPhone (Retina 4-inch) under Hardware -> Device menu, it works fine.

    I have no idea how you'd make this work on both devices yet. Seems like there's a way to tell it to be more fluid in layout, but I don't know how yet.
  • We tried to cover this at different points in the book, but but unfortunately configuring constraints in the current version of Xcode is difficult to do properly, and explaining how to do it properly is almost impossible :(

    However, Xcode 5 seems to have solved this pretty nicely. It stays out of your way most of the time, and doesn't automatically create new constraints behind your back all the time! If you want to work with constraints, you might want to download a developer preview of Xcode to see how it will be handles in the near future.
Sign In or Register to comment.