0

in my application, on ipad version, i open a detail VC with modalPresentationStyle = .formSheet, now over this VC i want to open another VC in pagesheet mode. This is my code:

func showFittedSheet(_ innerViewController: UIViewController, size: CGFloat? = nil, completion: (() -> Void)? = nil) {
    innerViewController.modalPresentationStyle = .pageSheet
            
    if let sheet = innerViewController.sheetPresentationController {
        sheet.prefersScrollingExpandsWhenScrolledToEdge = false
        sheet.prefersGrabberVisible = true
        if #available(iOS 16.0, *), let size = size {
            sheet.detents = [
                .custom { _ in
                    size - 60
                },
            ]
        } else {
            sheet.detents = [.medium(), .large()]
        }
    }
            
    present(innerViewController, animated: true) {
        completion?()
    }
}

The code work, but my second VC is opened outside first VC in center bottom of the screen. Same problem if the first VC is a .formSheet of a .popover.

Is there the possibility to show the second VC inside the first VC?

Fast
  • 121
  • 10

0 Answers0