如何在iPad中检查设备方向从纵向更改为横向和副反面 [英] How to check Device Orientation Change From Portrait To Landscape and Vice-Versa in iPad
本文介绍了如何在iPad中检查设备方向从纵向更改为横向和副反面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个拆分视图控制器,我在其中提出一个弹出窗口。现在,当设备方向从横向变为纵向时,我必须运行一段代码&如果它从纵向变为横向,我必须运行另一段代码。如何在Swift中实现这一点。
I have one split view controller and i am presenting a popover inside it. Now when the device orientation is changing from landscape to portrait i have to run a piece of code & if it is changing from portrait to landscape i have to run another piece of code. How to achieve this in Swift.
推荐答案
从iOS 8.0您可以使用以下方法检测方向更改。
From iOS 8.0 You can detect the orientation change using below method.
在objective-c
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
in swift
func viewWillTransitionToSize(_ size: CGSize,
withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator)
从您可以找到的大小。
这篇关于如何在iPad中检查设备方向从纵向更改为横向和副反面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文