Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Presenting LightBoxController doesn't work. #282

Open
iamimsh opened this issue Oct 5, 2021 · 1 comment
Open

Presenting LightBoxController doesn't work. #282

iamimsh opened this issue Oct 5, 2021 · 1 comment

Comments

@iamimsh
Copy link

iamimsh commented Oct 5, 2021

I've updated to the latest version, I saw in previous version that this issue was resolved. However, it isn't solved yet.
App freezes when presenting LightBoxController.

@lexonli
Copy link

lexonli commented May 2, 2022

Don't know if we have the same problem, but when trying to present Lightbox from a .pageSheet modalPresentationStyle (the default style now in iOS 13) I get a transparent screen that blocks anything from happening.

My solution (workaround) was to just start an empty view controller on .fullScreen and then present lightbox from there

Here's a helper class, maybe it helps:

class FullScreenImageViewController: UIViewController {
    
    private var controller: LightboxController?
    private var hasDisplayed = false
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .black
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        guard let controller = controller else {
            return
        }
        if hasDisplayed {
            dismiss(animated: false, completion: nil)
        } else {
            hasDisplayed = true
            controller.modalPresentationStyle = .fullScreen
            controller.dynamicBackground = true
            present(controller, animated: true)
        }
    }
    
    func configure(image: UIImage) {
        controller = LightboxController(images: [.init(image: image)])
    }
    
    func configure(imageURL: URL) {
        controller = LightboxController(images: [.init(imageURL: imageURL)])
    }
}

Usage

let fullScreenImageScene = FullScreenImageViewController()
fullScreenImageScene.modalPresentationStyle = .fullScreen
fullScreenImageScene.configure(image: myImage)
present(fullScreenImageScene, animated: false)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants