I want to add two images to single image view (i.e for landscape one image and for portrait another image)but i don\'t know how to detect orientation changes using swift lan
Swift 4+:
I was using this for soft keyboard design, and for some reason the UIDevice.current.orientation.isLandscape
method kept telling me it was Portrait
, so here's what I used instead:
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
if(size.width > self.view.frame.size.width){
//Landscape
}
else{
//Portrait
}
}