【发布时间】:2019-12-28 17:01:04
【问题描述】:
我正在为数学课程和练习做一个应用程序......
我只编写了 MainMenu,但我遇到了问题。 事实上,我想知道当前的方向来设置我的东西。
但是,我尝试了不同的方法来了解当前的方向,但我没有成功:
if UIDevice.current.orientation == UIDeviceOrientation.portrait {
NSLog("Portrait")
}
else if UIDevice.current.orientation == UIDeviceOrientation.landscapeRight || UIDevice.current.orientation == UIDeviceOrientation.landscapeRight {
NSLog ("Landscape")
}
我也看到了这个答案,但它不起作用(或者我可能不太了解):Getting device orientation in Swift,bu
我想在 ViewDidLoad() 中指定我在 UIViewController 中。
感谢您的帮助????????
【问题讨论】:
-
覆盖函数
viewDidLayoutSubviews()