CL So
CL So

Reputation: 3759

Is it possible to set a view over a modal view?

In this ViewController, it will present a modal view.

After the modal view presented, how to set the following views to over the modal view?

The first view is UIImageView in current ViewController.

The second view is another modal view, in this example, modalViewController2 will display under the first one.

class ViewController: UIViewController {

    @IBOutlet weak var img: UIImageView!

    override func viewDidAppear() {
        super.viewDidAppear()

        self.modalViewController = self.storyboard!.instantiateViewController(withIdentifier: "modal") as! ModalViewController
        self.modalViewController!.modalPresentationStyle = .overCurrentContext
        self.present(self.modalViewController!, animated: true, completion: nil)


        self.modalViewController2 = self.storyboard!.instantiateViewController(withIdentifier: "modal2") as! ModalViewController2
        self.modalViewController2!.modalPresentationStyle = .overCurrentContext
        self.present(self.modalViewController2!, animated: true, completion: nil)
    }
}

Upvotes: 1

Views: 192

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100503

First presenting a view controller should be in viewDidAppear as in viewDidLoad view's hierarchy is not yet complete , second you can't present 2 modal VCs at the same time , better way to make only one modal VC and construct it with say 2 views and manage hide/show for each one according to your need

Upvotes: 2

Related Questions