简体   繁体   English

处理设备旋转显示

[英]Handling Device Rotation Displays

I've got a fairly intricate IOS application with icons, tables, text fields, etc spanning across over 20 different view controllers. 我有一个相当复杂的IOS应用程序,其图标,表格,文本字段等跨20多种不同的视图控制器。 I built the entire application in portrait mode, and have of course realized that things look screwy when in landscape. 我以纵向模式构建了整个应用程序,当然,我意识到在横向模式下看起来有些麻烦。

For the really simple screens I've had little issues using autolayout's constraints to accommodate any orientation changes. 对于真正简单的屏幕,使用自动布局的约束来适应任何方向变化几乎没有什么问题。 However, when there are multiple (5+) items on the screen I've found it incredibly hard to use constraints to manage everything. 但是,当屏幕上有多个(5+)项时,我发现很难使用约束来管理所有内容。 In fact some views look like they need the entire layout transformed to flow well. 实际上,某些视图看起来需要更改整个布局才能流畅地流动。

Is there a better alternative to constraints? 有没有更好的替代约束条件? My only other thought is to make duplicate views, one for portrait and one for landscape. 我唯一的其他想法是制作重复的视图,一个用于肖像,另一个用于风景。 Then I can just switch on the deviceOrientationChange listener. 然后,我可以打开deviceOrientationChange侦听器。

You can always switch off constraints by selecting the xib/storyboard file and unchecking Use Autolayout . 您始终可以通过选择xib / storyboard文件并取消选中Use Autolayout来关闭约束。 To do this only for the more complicated views, I think breaking out into separate xibs is feasible. 为了仅针对更复杂的视图执行此操作,我认为将其分解为单独的xib是可行的。

Also, sometimes landscape really calls for a complete rearrangement of the view (or even adding / hiding certain elements). 另外,有时风景真的需要对视图进行彻底的重新排列(甚至添加/隐藏某些元素)。 You should not shy away from defining separate views for this, with or without xib documents. 无论有没有xib文档,您都不应避开为此定义单独的视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM