开发者

how do I keep buttons on a XIB view in the same relative position after orientation change?

how do I keep buttons on a XIB view in the same rel开发者_如何学JAVAative position after orientation change?

So I have:

  • The base application is based on the XCode 4 template "Utility Application", has a MainView & FlipSideView controller
  • On the Main View here I have on the XIB Interface Builder design layout in portrait (a) my button in bottom left, (b) a UILabel in the bottom middle, and (c) on the bottom right is the little "i" button to flick over to the flipsideview
  • I note when I go from portrait to landscape the templates's "i" button in bottom right still stays on the bottom right, however my buttons (i.e. a & b from above) aren't keeping their relative position.

So how would I keep these buttons in the bottom left and bottom centre respectively after orientation change? Is this achievable in IB or does it require code somewhere (if so a small code example would be nice)?


There is a tab in interface builder where you can set resizing options, I had a simular problem last week as I am relatively new to iOS development, when on that tab you can set how the application should respond to changes in the size of the view, in other words when the orientation changes the size of the view also changes and the buttons need to know how to resize. No code needed because interface builder rocks. You can google how to port an iPhone app to iPad they cover some of the resizing stuff, and also have a look at this blog, it has a bunch of handy tutorials on iOS development, there is one on iPhone to iPad porting, which will cover device rotation. http://www.raywenderlich.com/tutorials


You can do it using IB.First you should select your button thent go to the Size Insepector of interface builder and then in Auto "sizing" section under "origin" you can set different position and size of you button


Select button and go to Size inspector(5th button like Ruler Below View & Editor in Top right corner) and select Autosizing Box and configure button how you want to Show it..

Follow this tutorial it will give you perfect Idea..

http://www.thenewboston.com/?p=1386&pOpen=tutorial

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜