iPad的纵向和横向模式使用不同的Xib [英] Different Xib's for Portrait and Landscape mode for iPad

查看:70
本文介绍了iPad的纵向和横向模式使用不同的Xib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对将2个XIb用于一类改变Ipad方向的设备表示怀疑.这是正确的做法吗?对于人像"模式下的Ipad,我有一种设计;对于风景"模式,我有不同的设计(有点像人像,但不能调整为人像).我可以在使用2 Xib的程序中做一切事情还是做得好吗,在使用2 Xib的程序中我应该面对什么复杂性或问题?

I have doubt in using 2 XIb's for one class changing on orientations for Ipad. Is it right practice to do? For Ipad in Portrait mode I have one design and for landscape mode I have different design (little similar to portrait, but can't adjust' in portrait). Can I do everything in programming or its fine in using 2 Xib's, what are the complexities or issues I should face in using 2 Xib's?

推荐答案

如果您要问使用两个NIB进行定向是否是标准做法,那么答案是否定的.

If you're asking if using two NIBs for your orientations is standard practice then the answer is no.

如果您的横向和纵向UI根本不同,那么这将是一种更可接受的方法.但是,您可以轻松地使用一个具有两个视图的NIB(一个用于风景,一个用于肖像).

If your UIs for landscape and portrait are radically different then it would be a more acceptable approach. But you could easily just use a single NIB with two views inside it (one for landscape, one for portrait) instead.

Apple提出的公认设计模式是您的视图控制器可以管理横向和纵向方向,并可以调整其视图(使用自动调整大小的蒙版,还可以插入旋转时触发的各种委托方法以添加/删除/动画化视图) )或将视图替换为其他视图.

The accepted design pattern that Apple put forward is your view controller manages both landscape and portrait orientations, and either adjusts its view (using autoresizing masks, and also hooking into the various delegate methods triggered upon rotation to add/remove/animate views) or replaces the view with something else.

如果您的风景/人像视图截然不同,我建议您使用一个带有两个视图的NIB(一个用于风景,一个用于肖像),并在检测到旋转时在视图控制器中添加/删除这两个视图.

If your landscape/portrait views are quite different I'd recommend having a single NIB with two views inside it (one for landscape, one for portrait) and adding/removing those two views inside your view controller when you detect rotation.

标准做法"总是很难定义的,也许有些人会不同意我的看法,但是我当然没有见过任何使用两个NIB进行横向/人像定向的应用程序,也没有见过Apple可以执行此操作的示例代码.希望这会有所帮助!

'Standard practice' is always quite difficult to define, and perhaps some people will disagree with me, but I certainly haven't seen any apps that use two NIBs for their landscape/portrait orientations, and I haven't seen any Apple sample code that does it either. Hope this helps!

这篇关于iPad的纵向和横向模式使用不同的Xib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆