![](/img/trans.png)
[英]Different orientation behavior of modalviewcontroller between iphone and ipad
[英]Different behavior between iPhone and iPad
我在iPhone 6 plus和iPad Pro上運行相同的代碼,他們沒有同樣的反應。 當設備方向改變時調用一個函數,然后我只用以下代碼打印視圖的寬度:
override func viewDidLoad(){
super.vewDidLoad()
NotificationCenter.default.addObserver(self, selector: #selector(MyClass.rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
}
func rotated(){
print(self.view.bounds.width)
}
在iPhone上我得到旋轉后的寬度,但在iPad上我得到旋轉前的寬度。 謝謝你的幫助!
您可以嘗試在視圖控制器功能中獲取寬度:
func viewDidLayoutSubviews()
如果這有幫助,請告訴我!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.