1

I'm new to the iOS swift scene and i was hoping you would be able to help me find a solution or send me on an alternative route to achieving this.

Here is the diagram to my Application Interface Structure

So, i have the ContainerVC which has a UIScrollView, and that UIScrollView has a the four ChildVCs inside. My problem is when i present the ModalVC from one of the ChildVCs, the ContainerVC, which has the UIScrollView and the application's background disappears from the screen completely and the background of the app becomes black. I believe that happens because iOS thinks that the ContainerVC is no longer being used so it removes it from the hierarchy when the modal is presented on top of the ChildVC.

I wanted to be able to have the ContainerVC, which provides a background for the app and the UIScrollView where the ChildVC are embedded, visible at all times even when a ChildVC presents the ModalVC modally. Before the ModalVC is presented, the ContainerVC can be seen behind the ChildVC around the edges (modal ahah) of the screen and everything is fine, but that changes when i trigger a tap event and i present the modal. Here is the before and after: Before Tap Event >>> After Tap Event & ModalVC appears

You can see that the purple background disappeared now that the ModalVC is presented and though you cant see it, I'm not able to scroll side ways anymore because the UIScrollView isn't there either.

How can i present the ModalVC from the ChildVC without losing the ContainerVC and its UIScrollView inside? i.e. from disappearing and staying the the view hierarchy

Here is the code is use to present the ModalVC from a given ChildVC.

func didTapCell(origin: String) {
            let modalVC = storyboard?.instantiateViewController(withIdentifier: "overlayModal") as! OverlayModalViewController
            let appDelegate = UIApplication.shared.delegate as! AppDelegate
            appDelegate.window?.rootViewController = self // i think this self has something to do with the background disappearing 
            modalVC.modalPresentationStyle = .overCurrentContext
            self.present(modalVC, animated: true, completion: nil)
}

I have been looking for a solution for a while now but i can't seem the figure it out. I would be great if you could help work this out or help find a way around it and achieving the same. Please help me out.

Thank you in advance. Please let me know if there's anything i can do to clarify anything.

pluto
  • 11
  • 1

0 Answers0