GSImageViewerController
GSImageViewerController copied to clipboard
How to open GSImageViewerController in landscape mode (depending on current orientation).
I would like to open an image depending on the device's current orientation. For example if device is in landscape mode image should rotate. Now it is showing in portrait mode only and not rotating in landscape mode.
You can inherit GSImageViewerController and try to modify it.
see https://github.com/wxxsw/GSImageViewerController/issues/28
Late in the party! I'm still happy to help you guys.
Use supportedInterfaceOrientationsFor application delegate and add the following code in the AppDelegate file.
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if isLandscape {
return UIInterfaceOrientationMask.all
}else{
return UIInterfaceOrientationMask.portrait
}
}
Add this line to your GSImageViewerController file
override func viewDidLoad() {
super.viewDidLoad()
isLandscape = true
}
override func viewWillDisappear(_ animated: Bool) {
isLandscape = false
}
And don't forget to add a global variable in the app delegate file
var isLandscape = false
Also, I suggest adding 'GSImageViewerController.swift' to your project instead of using a pod file to avoid file override issues in the future while a pod updates.