iOS 16 orientation change
2023. 1. 27. 11:55ㆍiOS/이슈
iOS 16 들어와서 AVasset 관련도 그렇고 추상화, 비동기가 강조된 느낌이다.
프로젝트 설정은 Portrait Only로 설정되어 있음
// AppDelegate에서 orientation 값을 바꿔줘야한다.
var myOrientation: UIInterfaceOrientationMask = .portrait
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?
) -> UIInterfaceOrientationMask {
return myOrientation
}
// Landscape ViewController
// 지원할 오리엔테이션 모드
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .allButUpsideDown
}
func rotate(orientation: UIInterfaceOrientationMask) {
let appDelegate = UIApplication.shared.delegate as? AppDelegate
appDelegate?.myOrientation = orientation
if #available(iOS 16.0, *) {
self.setNeedsUpdateOfSupportedInterfaceOrientations()
self.view.layoutIfNeeded()
return
}
if orientation == .portrait {
let value = UIInterfaceOrientation.portrait.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
} else if orientation == .landscapeRight {
let value = UIInterfaceOrientation.landscapeRight.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
} else if orientation == .landscapeLeft {
let value = UIInterfaceOrientation.landscapeLeft.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
}
}
남은 이슈
제스처 이벤트를 통한 rotate()는 되는데
UIDevice.orientationDidChangeNotification을 이용한 rotate()는 바로 동작을 안하고 UI가 새로 그려질 때(statusBar를 내리거나, foreground로 돌아올 때)만 동작한다.
메인 쓰레드에서 동작하는데 의문임
출처
Force landscape mode in one ViewController using Swift
I am trying to force only one view in my application on landscape mode, I am calling: override func shouldAutorotate() -> Bool { print("shouldAutorotate") return false } overr...
stackoverflow.com
'iOS > 이슈' 카테고리의 다른 글
잘못된 코드로 인하여 AWS 폭탄 맞은 이야기 (0) | 2023.03.17 |
---|---|
[AVAsset]에서 duration load delay 이슈 (0) | 2023.02.03 |
cancel cell's gestures when scroll (1) | 2023.01.19 |
XCode Run 시뮬레이터는 되는데 Device에서 안 되는 이슈 (0) | 2022.11.07 |
PhotoLibrary Video: Unable to issue sandbox extension error code -1 (0) | 2022.10.18 |