弹出仅横向视图后,ViewController的方向错误 [英] ViewController has wrong orientation after Landscape-only has been popped

查看:56
本文介绍了弹出仅横向视图后,ViewController的方向错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在基于导航的应用程序中,LandscapeViewController仅支持横向模式(所有其他模式均支持这两种模式).我也有一个加载屏幕",建议用户在继续操作之前先旋转手机.这样,我可以确保在加载风景视图时,它处于风景模式.

In a navigation-based app, LandscapeViewController only supports landscape mode (all others support both modes). I also have a "loading screen" that advises the user to rotate the phone before continuing. This way I can make sure that when my landscape view loads, that it's in landscape mode.

当我在仍然显示LandscapeVC的情况下将手机旋转到纵向模式时,就会出现问题.我按后退"导航按钮向上浏览一个级别(到同时支持横向和纵向模式的VC),但是即使手机处于纵向模式,上一级也会以横向模式显示.我猜这是因为当我离开此视图时,我处于纵向模式,然后在另一个视图中旋转了手机,因此该视图尚未收到通知.然后,如果我继续将手机旋转到其他横向模式(例如,将LandscapeVC加载在其右侧,因此我将上部VC从纵向旋转到左侧横向模式),它将进行更新.

The problem comes when I rotate the phone to portrait mode while still showing LandscapeVC. I press the Back navigation button to navigate up one level (to a VC that supports both landscape and portrait modes), but the upper level shows in landscape mode even though the phone is in portrait mode. I guess this is because when I left this view I was in portrait mode, I then rotated the phone while in another view, so this view has not received the notification. If I then proceed to rotate the phone to the other landscape mode (say the LandscapeVC was loaded on its right side, so I'd rotate the upper VC from portrait to the left landscape mode), it will update.

我的问题是:我怎样才能通知此上部视图电话已旋转,因此当用户将电话置于纵向模式后用户上升时,上部视图正确显示了吗?

My question is: how can I notify this upper view that the phone was rotated, so when the user goes up after putting the phone in portrait mode, the upper view shows correctly?

推荐答案

在将子视图弹出堆栈并返回上一个视图的位置(当前停留在风景中,您想以肖像画),您可以尝试将其发送到 setNeedsLayout 选择器.

Where you pop the sub-view off the stack and return to the previous view (currently stays in landscape, you'd like in portrait), you could try sending it to the setNeedsLayout selector.

这篇关于弹出仅横向视图后,ViewController的方向错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆