简体   繁体   English

处理iPhone方向横向/纵向

[英]Handle iPhone orientation Landscape/Portrait

I have an iPhone app that has several different view controllers. 我有一个iPhone应用程序,它具有几个不同的视图控制器。 A login screen and then three other view controllers that contain table views. 登录屏幕,然后是包含表视图的其他三个视图控制器。 I am using the storyboard, not NIB files, and have designed each view in a portrait orientation on the storyboard. 我使用的是情节提要,而不是NIB文件,并且已在情节提要中纵向设计每个视图。 When I run my app, the login screen switches between landscape/portrait when I turn the device and looks just fine. 当我运行我的应用程序时,当我打开设备时,登录屏幕会在横向/纵向之间切换,看起来还不错。 However, the other screens do not change...well, actually they WILL change from landscape to portrait, but they won't change from portrait to landscape. 但是,其他屏幕不会更改...嗯,实际上,它们会从横向更改为纵向,但不会从纵向更改为横向。 If I am on the login view, then navigate to the other views I can see them in landscape, but as soon as I turn the device and it switches to portrait, it's stuck until I go back to the login screen. 如果我在登录视图上,请导航至其他视图,以横向查看它们,但是一旦我转动设备并将其切换为纵向视图,它就会卡住,直到我返回登录屏幕为止。

I've searched and found answers that involve NIB files, but nothing about how to work with the device orientation when using the storyboard. 我搜索并找到了涉及NIB文件的答案,但与使用情节提要板时如何使用设备方向无关。 Am I missing some property to set on the view? 我是否缺少一些要在视图上设置的属性? How can I get my table views to work like my login view and automatically switch the orientation automatically? 如何使表格视图像登录视图一样工作并自动自动切换方向?

If you want to lock the view orientation in code you lock it with this: 如果要在代码中锁定视图方向,可以使用以下方法锁定它:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

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

相关问题 屏幕方向(如iPhone中的纵向和横向) - screen orientation like portrait and landscape in iphone 在应用程序iPhone中管理方向风景和人像 - Manage orientation landscape and portrait both in a app iPhone 适用于iPhone的纵向方向和适用于iPad的横向方向的通用应用程序 - Universal application with Portrait orientation for iPhone and Landscape orientation for iPad 方向肖像和风景模式 - Orientation portrait and landscape mode iPhone的自定义选项卡栏将选项卡纵向更改为横向 - Custom Tab Bar for iPhone changes tabs portrait to landscape orientation iPad / iPhone开发人员:displayViewController以风景方向渲染肖像 - iPad/iPhone Dev: displayViewController Is Rendering Portrait in Landscape Orientation iphone - 当设备处于纵向时,以编程方式将系统键盘旋转到横向 - iphone - programmatically rotate system keyboard to landscape when device is in portrait orientation iphone:在导航时强制改变从纵向到横向的方向 - iphone: Forcefully change orientation from portrait to landscape on navigation iPhone的初始肖像方向负载给横向视图元素宽度 - iphone initial portrait orientation load is giving element width of landscape view 从横向方向从iPhone 6 Plus主屏幕启动纵向导致错误的方向 - Launching into portrait-orientation from an iPhone 6 Plus home screen in landscape orientation results in wrong orientation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM