5

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.

Taz
  • 1,203
  • 1
  • 11
  • 21
  • 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 May 05 '16 at 13:48
  • I'd suggest you to use `delegates` in this case – Shamsiddin Saidov May 05 '16 at 13:49
  • 1
    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 solved – Sandeep Bhandari May 05 '16 at 13:52
  • 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 May 06 '16 at 16:38
  • @taz : Glad you solved it buddy :) – Sandeep Bhandari May 06 '16 at 19:13
  • can u provide more code? I have same problem – famfamfam Aug 25 '18 at 11:56

1 Answers1

-1

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
        }
    }
}
tuyen le
  • 305
  • 5
  • 11