5
votes

Is it possible to interact with a presenting view controller whilst a model view controller is being presented?

 ------------
|            |
|    VC1     |
|            |
|            |
|            |
|            |
|------------|
|    VC2     |
|            |
 ------------

In the illustration above VC1 is the presentingViewController and VC2 is the presentedViewController. The user experience I am trying to achieve is that the user can interact with VC1 and VC2. At the moment, touches are not passed through to VC1 when VC2 is presented.

1
why dont you add VC2 as subview and bring it with animation as if it is being presented modally that way controll will always be in single controller just two views being renderred :)Sandeep Bhandari
I'd suggest you to use delegates in this caseShamsiddin Saidov
My solution will be :) add two view's to VC1, view1 will cover full screen and a containerView below view1 with height constraint as 0. this conatainer will load VC2's view :) whenever you want to show VC2 screen change the height consatrint in animation block :) So when loaded it will show VC2 screen, because control never left VC1, VC1 is still active and can take touches and as per VC2 it is renderred in container view of VC1 so it will also respond to touch :) problem solvedSandeep Bhandari
Thanks @SandeepBhandari, that's the exact approach I thought up after posting this question. Just pushed to master and now read your comment ... glad it's consistent :)Taz
@taz : Glad you solved it buddy :)Sandeep Bhandari

1 Answers

-1
votes

I might be late to this but assuming you want your VC2 to be half screen. This allows you to interact with both VC1 and VC2

class CustomListPlacesTableViewController: UIPresentationController {
    override var frameOfPresentedViewInContainerView: CGRect {
        get {
            containerView?.frame.origin.y = UIScreen.main.bounds.midY
            containerView?.backgroundColor = .black
            return super.frameOfPresentedViewInContainerView
        }
    }
}