// 端末の向きがかわったらNotificationを呼ぶ設定.-> viewDidLoadに記載
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.onOrientationChange), name: UIDevice.orientationDidChangeNotification, object: nil)
// 端末の向きがかわったら呼び出される.
@objc func onOrientationChange(_ notification: Notification){
//print(“onOrientationChange/pass”)
let deviceOrientation: UIDeviceOrientation! = UIDevice.current.orientation
// 向きの判定.
if deviceOrientation.isLandscape {
// code
} else if deviceOrientation.isPortrait {
// code
} else {
// code
}
}