0
votes

I'm presenting a NavigationViewController in iPad app as formSheet, which works great. But in this presented NavigationViewController when I push QLPreviewController with one Image to display it resizes it self to fit the Image. This alone would not have been a problem but upon going back to previous viewController form QLPreviewController the resized viewController size affect all ViewControllers in that NavgationViewController.

If there is any way to go back to default size for viewController on coming back from QLPreviewController it would help too. Or If QLPreviewController doesn't resize when pushed.

Also this problem is only in iOS 13+.

Any help would be appreciated.

1

1 Answers

0
votes

Finally, I resolved it on my own.

Create one Variable

var defaultPreferredContentSize: CGSize?

and one method

fileprivate func adjustViewControllerSizeIfNeeded() {
    if let size = defaultPreferredContentSize {
        if self.navigationController?.preferredContentSize != size {
            self.navigationController?.preferredContentSize = size
        }
    } else {
        defaultPreferredContentSize = self.view.frame.size
    }
}

Call this method in viewDidAppear

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    adjustViewControllerSizeIfNeeded()
}