Reputation: 6583
Is there anyway to support only Landscape mode on iPad and disallow rotations to Portrait mode with size classes enabled? All views are laid out in storyboard with auto-layout enabled.
Upvotes: 0
Views: 97
Reputation: 1340
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
switch UIDevice.current.userInterfaceIdiom {
case .phone:
return UIInterfaceOrientationMask.portrait
case .pad:
return UIInterfaceOrientationMask.landscape
case .unspecified:
return UIInterfaceOrientationMask.portrait
default:
return UIInterfaceOrientationMask.portrait
}
}
override var shouldAutorotate: Bool {
return false
}
1) implement these two method in your viewcontroller.
2) Then go to storyborad and select your viewcontroller
3) Then from below select option ipad
4) change orientation to landscape
5) then click vary on trait button
6) Now your view controller is in landscape mode, so give constraints of view whatever you like .it will change for ipad only because you have selected ipad.
7) after that click done varying. and its over
Upvotes: -1