我使用的是Xcode9.4。在.xcodeproj文件的“常规”选项卡下,我已取消选中“纵向”和“倒置”选项。尽管如此,应用程序还是会同时旋转到这两种模式。请帮我做同样的事
提前谢谢你。
发布于 2019-02-20 17:24:56
如果旋转设备、按下viewController等,则返回AppDelegate。此函数始终调用
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask
{
return self.restrictRotation
}使用方法:
在AppDelegate中:
var restrictRotation:UIInterfaceOrientationMask = .portrait调用ViewDidLoad或viewWillAppear方法时在viewController中。我们将像这样改变:
(UIApplication.shared.delegate as! AppDelegate).restrictRotation = .all 然后调用AppDelegate上的这个方法。
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMaskhttps://stackoverflow.com/questions/54782459
复制相似问题