ios - React on Modal ViewController being dismissed -
I have three ViewControllers and one navigation controller I Navigation stack:
Navigation controller-push-> VC1- Push-> VC-2 can form VC3 in the code formally in VC1. It is not connected through segues.
VC1 - "Your current projects"
VC2 - "Details of your project"
VC3 - "Create a new project"
When a new user, I vc3 I am using:
- (IBAction) newProjectButton: (ID) sender {NewProjectViewController * newProject = [[NewProjectViewController alloc] init]; UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController: newProject]; [Self-present ViewController: animated navController: yes complete: zero]; }
I press the "Cancel" button on the user, I use this code:
- Cancel (IBAction) button: ( ID) Sender {{self dismissViewControllerAnimated: Yes complete: zero]; }
When the user presses the "full" button, then I create VC1 to CC in VC2 and show the properties of the new project. I would like this Segue to be invisible to the user, so he only sees this series of events:
Press the "Add" button -> Modal VC looks -> Press "Done" -> Model VC disappear And VC3 has already been shown.
I am asking how to tell the user how to press the button "Don" to VC1? Is the delegation possible here? How to implement it? Thank you.
You must create a representative protocol that allows the Model View Controller to send notifications to its creator .
@protocol modalViewControllerDelegate @optional - (zero) modalViewControllerDidCancel: (ModalViewController *) vc; - (BOOL) modalViewControllerShouldSave: (ModalViewController *) vc; @end
Then, in ModalViewController
you define a new property weak
is important because you do not want to have a circle Are there.
@property (nonatomic, weak) id & lt; ModalViewControllerDelegate & gt; Representative; Before rejecting or saving, check whether the representative has applied the methods (via - correspondsToSelector:
) and send the appropriate callback. Do not forget to set up your representative property while setting up your Model View Controller.
Comments
Post a Comment