IOS: reject two viewController

I have three viewController

First, second and third

from second to third. I use

Third *third = [[Third alloc]initWithNibName:@"Third" bundle:nil]; [self presentModalViewController:third animated:YES]; [third release]; 

Now I want to return from the third to the first; then I set to viewDidAppear in the second of this code:

 [self dismissModalViewControllerAnimated:NO]; 

but for 1 second I see a second, and I do not want to watch it ... how can I do this?

+6
source share
3 answers

You need to first disable the third view controller, and then the second Viewcontroller. Run the following code when you want to switch to the first view controller.

 -(void)goToFirstView{ UIViewController *vc = [self parentViewController]; // UIViewController *vc = [self presentingViewController]; //ios 5 or later [self dismissModalViewControllerAnimated:NO]; [vc dismissModalViewControllerAnimated:YES]; } 
+15
source

How is the third kind of modality removed? Did the user click the Finish button? If so, then in the button handler you want to remove both.

You can reject both values:

 [self dismissModalViewControllerAnimated: YES]; [self.presentingViewController dismissModalViewControllerAnimated: NO]; 
+4
source

This happens when coz viewDidAppear is called every time before the view, so as soon as it appears, you drop it and it disappears.

I don’t think that what you are trying to do can be achieved using modalViewControllers ... instead use navigationController and keep adding your view controllers to the stack, and when you want to go to the First view controller, just call

  [self.navigationController popToRootViewControllerAnimated:YES]; 

EDIT :

just thought about it, this can be achieved through delegation. You make the second delegate to the third, and as soon as you reject the third control, send a message to the delegate. In this message, call [self dismissModalViewControllerAnimated:NO]; .. and you are done .. (quite easy if you know the delegation.)

0
source

Source: https://habr.com/ru/post/913556/


All Articles