1

In my iPad app, the view controller include three button, one navigation bar and one tool bar.
When i rotate my view controller from portrait to landscape mode, three buttons are disorder.
The navigation bar also collapse to tool bar.
How can i do it?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Night Hunter
  • 123
  • 1
  • 2
  • 13

2 Answers2

1

You need to learn about layout. You can lay out subviews of your view in three ways:

  • Manually

  • Autoresizing (springs and struts)

  • Autolayout (constraints)

If this is a new project in Xcode 4.5 or later, you are using autolayout by default. So you need to go back into the nib and edit the constraints that Xcode already gave you, because obviously they are not what you want.

You might want to read the Layout section of my book, which has extensive discussion of how autolayout works and how to edit constraints in the nib: http://www.apeth.com/iOSBook/ch14.html#_layout

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

Ideally you should keep your content under one xib per view controller, linking your buttons and nav bars by pinning to your layout should rotate properly; however there is one other option for a viewing a different xib when the device is rotated, see the answer below.

Easiest way to support multiple orientations? How do I load a custom NIB when the application is in Landscape?

Community
  • 1
  • 1
Chad Adams
  • 1,319
  • 1
  • 9
  • 14