Search code examples
iosswiftuiscrollviewaddsubview

When a subview is displayed above the scroll view, it does not scroll


When a subview is displayed above the scroll view, it does not scroll.

My subview is displayed in the following way:

let reservationPopOverVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "reservationPopup") as! ReservationPopupViewController
        self.addChildViewController(reservationPopOverVC)
        reservationPopOverVC.view.frame = self.view.frame
        self.view.addSubview(reservationPopOverVC.view)
        reservationPopOverVC.didMove(toParentViewController: self)

Then a subview (reservationPopOverVC.view) appears, but the main view'a scrolling below it does not work. How can I solve this?


Solution

  • You should simply disable the user interaction for the view:

    reservationPopOverVC.view.isUserInteractionEnabled = false