Cancel modalviewcontroller from another modalviewcontroller

I am presenting a modalviewcontroller from another modalviewcontroller. When I fire the second modalviewcontroller, the first and second modalviewcontroller must be fired. I tried to access the first modal view, for example

[self.view.superview dismissmodalviewcontroller];  

but it shows an error. What is the correct way to get a link to the first modalViewController from the second and call the dismissal method from it?

+3
source share
6 answers

Like this.

A represents B. Here A is the parent of B (here A.modalViewController will be B and B.parentViewController will be A)

And B represents C. Here B is the parent of C (here B.modalViewController will be C and C.parentViewController will be B)

Apple, .

, C, rejectModalViewController C.parentViewController. C B, , B () , .

B. B B. [B.parentViewController rejectModalViewControllerAnimated: YES];

, B C C.parentViewController( ). , [B.parentViewController rejectModalViewControllerAnimated: YES];

+10

[self.parentViewController dismissModalViewControllerAnimated:YES];

+2

rejectModalViewControllerAnimated: UIViewController, UIView.

[self.parentViewController dismissModalViewControllerAnimated:YES];

, self.view.superview.

+2

, , , , :

[self.parentViewController.parentViewController dismissModalViewControllerAnimated:YES];
+2

, , -

[self.presentingViewController.presentingViewController dismissModalViewControllerAnimated:YES];
+1

, , .

:

        let transition: CATransition = CATransition()
        transition.duration = 0.5
        transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
        transition.type = kCATransitionReveal
        transition.subtype = kCATransitionFromBottom
        self.view.window!.layer.add(transition, forKey: nil)
        self.presentingViewController?.presentingViewController?.dismiss(animated: false, completion: nil)
0

All Articles