gordontucker / FittedSheets

Bottom sheets for iOS
MIT License
1.32k stars 278 forks source link

[Bug] Incorrect width when present a full screen ViewController in the Sheet #200

Open VitoNYang opened 1 year ago

VitoNYang commented 1 year ago

Presenting a ViewController with modalPresentationStyle = .fullScreen in a sheet view, when dismiss the ViewController will cause the width of the sheet view to be incorrect.

VitoNYang commented 1 year ago
image

Seems like the view.layoutIfNeeded() cause the width to incorrect

VitoNYang commented 1 year ago

According to the clue from PR #199,

this issue is trigger by SheetViewController's viewDidDisappear method,

image

So, I think we can fix this by checking if whether presenttedviewcontroller is nil

    public override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        // Add a guard statement to prevent unexpected dismiss
        guard presentedViewController == nil else { return }
        if let presenter = self.transition.presenter, self.options.shrinkPresentingViewController {
            self.transition.restorePresentor(presenter, completion: { _ in
                self.didDismiss?(self)
            })
        } else if !self.options.useInlineMode {
            self.didDismiss?(self)
        }
    }