Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dismiss Modal View

If I'm not mistaken, modal views have to be dismissed from the parent view, not from the modal view itself.

In my current project I have two modal views. In the first one, I pass data to the parent view. When the data is passed to the parent view, the dismiss is executed.

Now, I have another modal view that doesn't pass data to the parent view, so I don't know how to dismiss other than doing one self dismissModalView

Other than that, any other suggestion for a good practise on this topic?

Thanks in advance!

UPDATE:

From the answers I´m getting, I see I haven´t make myself very clear (not unusual, BTW).

I know how to self dismiss a modalViewController. That´s no problem. I also know how to use the protocol-delegate method to dismiss the modalViewController from the parent view when some data is passed.

My question is: how to dismiss the modalViewController from the parent view when no data is passed.

Thanks again!

like image 646
Marcal Avatar asked Nov 27 '22 06:11

Marcal


2 Answers

You can call from the modalView :

[self dismissModalViewControllerAnimated:YES];

But... If you want to have a constant coding pattern, whatever the modal view "returns" something or not, I suggest you to dismiss you views from the parent (the one that calls, the one that dismiss). But you can do both.

Does that answer your question ?

like image 167
Oliver Avatar answered Dec 08 '22 01:12

Oliver


Do take note that

[self dismissModalViewControllerAnimated:YES];

has been deprecated from iOS 6 onwards. Rather use

[self dismissViewControllerAnimated:YES completion:nil];
like image 31
Chris Avatar answered Dec 08 '22 01:12

Chris