Comments (8)
Hi guys. I have solution. It's tested in my project for iOS 10.x
In AppDelegate add variable
var restrictRotation: Bool = true
and method
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if restrictRotation {
return UIInterfaceOrientationMask.portrait
}
return UIInterfaceOrientationMask.all
}
Then when you tap on your image you have to implement next
func restrictRotation(_ restriction:Bool) {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.restrictRotation = restriction
}
func tapYourImage () {
restrictRotation(false)
}
Then when you finish to view pictures implement method willDismissAtPageIndex of SKPhotoBrowserDelegate
func willDismissAtPageIndex(_ index: Int) {
restrictRotation(true)
let value = NSNumber(value:UIInterfaceOrientation.portrait.rawValue)
UIDevice.current.setValue(value, forKey: "orientation")
}
from skphotobrowser.
I'm not entirely sure, but if you limit your app to one orientation, you can't really make an exception.
I would go at it the other way around:
- Allow all directions
- Make a subclass of UIViewController, where you limit the orientation to Portrait.
- Make sure all of your ViewControllers subclass your newly created VC
- Since the SKProtoBrowser doesn't subclass from your VC, it won't be limited to portrait.
Do you know what I mean? Please let me know if this helps out :).
from skphotobrowser.
I just had the same issue, I have an iPhone app which is in portrait only, and I wanted to have the SKPhotoBrowser to support all orientations.
The problem is, since SKPhotoBrowser is using a custom modal presentation style, the rotation doesn't work in the SKPhotoBrowser if the view controller presenting the SKPhotoBrowser doesn't support several interface orientations.
Even if you add shouldAutorotate
and supportedInterfaceOrientations
methods in the SKPhotoBrowser class.
The solution is to change the modal presentation style by using the fullscreen mode. Then it works, but the downside is that you will not have the background fading away as you're dismissing the photo (the transparent background is only accessible if you're using CurrentContext, OverFullscreen or Custom modal presentation style).
Hope it helps! :)
from skphotobrowser.
@arhangelskij that's the solution, from begining to end, thanks!
from skphotobrowser.
@arhangelskij worked like a charm! thanks mate!
from skphotobrowser.
Hi, seems the solution by @arhangelskij not work for me :(
from skphotobrowser.
I have another problem with this solution. If you slowly drag the photo down/up to dismiss you can see the view under the photo is landscape until willDismissAtPageIndex
is called and it changes it to portrait.
Is this the same for you as well? @arhangelskij
If there was only a delegate for willVerticalSwipeStart
to catch this as quick as possible.
many thanks
from skphotobrowser.
Since this issue is still open;
If anyone is looking for a solution to lock the orientation, you can extend SKPhotoBrowser as follows and lock the orientation.
extension SKPhotoBrowser {
open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .portrait
}
}
Happy coding.
from skphotobrowser.
Related Issues (20)
- SwiftUI Modal Dismiss Problem
- Can you play the video?
- Memory issue when images are very large HOT 1
- Can't compile in Xcode 13 beta 4
- Crush when GCD equals 0
- Build is failing due to SwiftLint rule 'shorthand_operator'
- 需要添加一个长按保存的回调
- Mixed Language in SwiftPM HOT 3
- 'SKPhoto' initializer is inaccessible due to 'internal' protection level HOT 1
- photoBrowser to present will case the unvisible tabbar show. HOT 3
- UI_USER_INTERFACE_IDIOM can't build in Xcode 13.3 HOT 4
- XCode Archive fails with abort trap 6 HOT 7
- Dynamically add url in skphotoBrowser is already presented
- XCode13.3.1编译不通过,Segmentation fault: 11 HOT 3
- Share button can't be hidden?
- UIImage+animatedGIF: `frameArray` crash HOT 4
- archive ipa error HOT 1
- Can it be downloaded directly from other apps?
- Is this framework no longer maintenance? HOT 1
- Why not add a thumbnail display HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skphotobrowser.