Domanda

I have this code:

    appDelegate.firstViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"firstviewcontroller"];
    appDelegate.secondviewcontroller = [self.storyboard instantiateViewControllerWithIdentifier:@"secondviewcontroller"];
    appDelegate.thirdViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"thirdviewcontroller"];
    appDelegate.fourthviewcontroller = [self.storyboard instantiateViewControllerWithIdentifier:@"fourthviewcontroller"];

    [self presentViewController:appDelegate.firstViewController animated:YES completion:nil];

Now in this way I allocated these viewcontrollers and I opened the firstviewcontroller with a modal mode with 'presentViewController'. OK, when I open firstviewcontroller I want manage all other viewcontroller inside it. In firstviewcontroller I have four button to pass at second or at third or at fourth, in the secondviewcontroller the same thing, I have four button to switch to first, third or fourth ecc...

To switch to one viewcontroller to another what instruction I should use? And If I want to exit from all? I just call

[self dismissViewControllerAnimated:YES completion:nil];

???

thanks

È stato utile?

Soluzione

You should use container view controller to do this. You can create a new and custom one or subclass UINavigationController or use it as is. That way you can keep all those VCs alive and provide transitions between them by accessing them with viewControllers method.

You can find more information here. You can look at Implementing a Container View Controller section.

You should definitely look at that page.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top