为什么我的观点仍然以景观呈现? [英] why is my view still presented in landscape?

查看:105
本文介绍了为什么我的观点仍然以景观呈现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的视图由导航控制器控制,因此我将支持的方向设置为导航控制器,以明确地纵向和纵向。 portraitUpSideDown,这是有效的,但如果前一个视图在调用视图时处于横向状态,它将呈现在横向并保持在横向,直到设备旋转..我该如何防止这种情况?

my view is controlled by a navigation controller, so I set the supported orientations in to the navigation controller to explicitly portrait & portraitUpSideDown and this works, however if the previous view was in landscape when the view was called upon, it will present itself in landscape and stay in landscape until the device is rotated.. How do I prevent this?

这是我的代码:

class EditProfileViewController: UIViewController, UINavigationControllerDelegate

override func viewDidLoad() {
        super.viewDidLoad()

        navigationController?.delegate = self
}

func navigationControllerSupportedInterfaceOrientations(navigationController: UINavigationController) -> UIInterfaceOrientationMask {

    return [UIInterfaceOrientationMask.Portrait, UIInterfaceOrientationMask.PortraitUpsideDown]
}

我以为上一行会永久地将视图锁定为肖像,我该怎么做?

I thought the previous line would lock the view into portrait permanently, how do I do so?

推荐答案

你可以在解雇之前将你的方向改回肖像:

You can change your orientation back to portrait before dismissing it:

UIDevice.current.setValue(UIInterfaceOrientation.portrait.rawValue, forKey: "orientation")

dismiss(animated: true) { _ in
    print("dismissed in Portrait mode")
}

这篇关于为什么我的观点仍然以景观呈现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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