开发者

Custom Landscape/portrait view

I would like to have my buttons arranged a specific way for my portrait view and and different way for my landscape view. I would also like to be able to add things to my landscape view that might now have been in my portrait view. The reasons i know this is possible is obviously, the calculator app that comes with every iphone. When you tilt it sideways into landscape it gives you a whole ne开发者_如何转开发w set of buttons. Does anyone know how to create a custom portrait view that is loaded when the iphone is right side up and how to create a custom landscape view when the iphone is on its side with different buttons?


You can try having two separate nib files for each orientation. You can customize the nib based on that.


  1. Create two different view controllers (i.e. NIB files or items in your storyboard). Call the classes MyViewControllerLandscape and MyViewControllerPortrait.

  2. Create a third view controller class programatically. Call it MyViewController, and make it the parent class of the landscape and portrait controllers.

    This makes it so that you can put all the common code for the two controllers in the parent class and put only the orientation specific code in the other two.

  3. Follow the instructions at http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/BasicViewControllers/BasicViewControllers.html#//apple_ref/doc/uid/TP40007457-CH101-SW26 to see how to switch between the landscape and portrait viewControllers.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜