自定义横向/纵向视图
我想让我的按钮以特定的方式排列为我的纵向视图和不同的方式为我的横向视图。我还希望能够将现在可能位于纵向视图中的内容添加到横向视图中。我知道这是可能的原因显然是每部 iPhone 都附带的计算器应用程序。当你将其横向倾斜时,它会给你一套全新的按钮。有谁知道如何创建在 iphone 正面朝上时加载的自定义纵向视图,以及如何在 iphone 侧面朝上时创建具有不同按钮的自定义横向视图?
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 new 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试为每个方向使用两个单独的笔尖文件。您可以在此基础上自定义笔尖。
You can try having two separate nib files for each orientation. You can customize the nib based on that.
创建两个不同的视图控制器(即 NIB 文件或故事板中的项目)。调用类 MyViewControllerLandscape 和 MyViewControllerPortrait。
以编程方式创建第三个视图控制器类。将其命名为 MyViewController,并使其成为横向和纵向控制器的父类。
这样您就可以将两个控制器的所有通用代码放入父类中,而仅将方向特定的代码放入另外两个控制器中。
按照
Create two different view controllers (i.e. NIB files or items in your storyboard). Call the classes MyViewControllerLandscape and MyViewControllerPortrait.
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.
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.