本文介绍了如何在iPhone中为横向编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我可以更改支持的界面方向,但是如果我希望横向视图与纵向视图完全不同或略有不同,我该如何编写代码?
I understand that I can change what interface orientations are supported, but if I want the landscape view to be entirely different, or somewhat different than the portrait view, how do I code for it?
谢谢.
推荐答案
为每个方向使用专用的视图控制器是最简单的方法.
Using a dedicated view controller for each orientation is the easiest approach.
如果唯一的区别是表示形式,而不是控制器逻辑,那么您还可以尝试编码单个视图控制器,以根据方向在两个视图之间交换.
If the only difference is presentation, not controller logic, then you could also try coding a single view controller to swap between two views depending on orientation.
例如伪代码
UIView *landscapeView = ...;
UIView *portraitView = ...;
when orientationChanged
{
if landscape then
[portraitView setHidden:YES];
[landscapeView setHidden:NO];
self.view = landscapeView;
else if portrait then
[landscapeView setHidden:NO];
[portraitView setHidden:YES];
self.view = portraitView;
[self.view setNeedsDisplay];
}
这篇关于如何在iPhone中为横向编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!