简体   繁体   English

设备方向更改时更改视图控制器

[英]changing view controller when the device orientation changes

Im making an ios app in xcode 4 and I need a way of changing what is displayed on the screen when the device orientation changes. 我在xcode 4中制作了一个ios应用程序,我需要一种方法来更改设备方向更改时屏幕上显示的内容。

does anyone know how to do this? 有谁知道如何做到这一点?

thanks. 谢谢。

probably you need to check first how to detect if the device orientation changes see here: how to detect orientation change 可能您需要首先检查如何检测设备方向是否发生变化,请参见此处: 如何检测方向变化

then on the example on the link, you should know ho to change the view which is displayed on the screen. 然后在链接上的示例中,您应该知道如何更改屏幕上显示的视图。 You can do it by using methods such as addSubview, presentModalViewController, pushViewController(for NavigationController) eg: 您可以使用诸如addSubview,presentModalViewController,pushViewController(用于NavigationController)之类的方法来实现,例如:

  • [self presentModalViewController:aView animated:YES]; [自身presentModalViewController:aView动画:是];
  • [self addSubview:aView]; [self addSubview:aView];
  • [self.navigationController pushViewController:aView animated:YES]; [self.navigationController pushViewController:aView动画:是];

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

相关问题 在更改设备方向时,呈现的SKScene将更改回到开始场景 - Presented SKScene changes back to start scene when changing the device orientation 设备方向更改时如何重新排列集合视图单元格 - How to rearrange collection view cell when device orientation changes 设备方向改变时以编程方式重绘视图的简单方法 - Simple way to redraw view programatically when device orientation changes 方向更改时,显示的视图控制器的框架错误 - Presented View Controller Has Wrong Frame When Orientation Changes 设备改变方向时如何处理AVPlayer? - How to handle AVPlayer when device changes orientation? 设备方向更改时切换到Differentnet UIViewController - Switch to a differnet UIViewController when the device orientation changes 更改设备方向时如何为uiimageview设置动画 - How to animate uiimageview when changing device orientation 当设备方向改变时改变UIImage - Changing UIImage when device orientation change 当用户更改设备方向时,如何仅旋转导航栏而不旋转视图? - When the user changes device orientation, how to rotate only the navigation bar and not the view? 当设备方向改变时如何旋转视图以保持正确的窗口大小 - how to rotate view when device orientation changes keeping the correct size of window
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM