简体   繁体   English

在设备方向更改时更改 UIView / UIViewController

[英]Change UIView / UIViewController on device orientation change

For those that use the iOS Calendar a lot, you know that when you change the orientation of the phone, another view is presented.对于那些经常使用 iOS 日历的人来说,你知道当你改变手机的方向时,会呈现另一个视图。 I am not sure oof this is changing to a subview, a new UIViewController, size classes or some programatic voodoo that Apple has spun.我不确定这是否会更改为子视图、新的 UIViewController、大小类或 Apple 开发的一些编程伏都教。

I can do some of the features with a subview that changes constrains on orientation change, but that is about it.我可以使用一个子视图来完成一些功能,该子视图会改变方向变化的约束,但仅此而已。 It looks crude and I thought there might be a better way to imitate the Calendar App.它看起来很粗糙,我认为可能有更好的方法来模仿日历应用程序。

It most likely uses UISplitViewController to achieve this effect.它很可能使用UISplitViewController来实现这种效果。 This lets you display two child view controllers side by side.这使您可以并排显示两个子视图控制器。

You can change its preferredDisplayMode property to show or hide secondary (or primary) view controller or set it to .automatic to let it choose the most appropriate layout for the available space.您可以更改它的preferredDisplayMode属性以显示或隐藏辅助(或主要)视图控制器或将其设置为.automatic以让它为可用空间选择最合适的布局。

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

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