1

I emerged a question using presentViewController and navigation between views. presentViewController makes the same view multiple times? or when you call the function only reopen the view if it is already open?

For example, if you call the next function form three different views:

HomeController *homeController = [[HomeController alloc] initWithNibName:nil bundle:nil];
[self presentViewController:homeController animated:YES completion:nil];

You have three homeControllers or only one?

Well, thanks!

sgb004
  • 347
  • 4
  • 14

1 Answers1

0

presentViewController:animated:completion: is for presenting a view controller modally. On iPhone, this if full screen, on iPad it depends on modalPresentationStyle. Generally, you wouldn't present the same modal 3 times.

However, it sounds like you're asking if 3 copies of:

HomeController *homeController = [[HomeController alloc] initWithNibName:nil bundle:nil];

Would create three instances of HomeController. The answer is yes. But you can reuse the same instance if needed by reusing the var.

garrettmurray
  • 3,338
  • 1
  • 25
  • 23
  • Oh, thank you, with this information only remains to find as close a view, to avoid having several times the same view. – sgb004 Aug 05 '13 at 22:17
  • You can close a modal with `dismissViewControllerAnimated:completion:`. – garrettmurray Aug 05 '13 at 22:20
  • If is correct, but get a warning that it is corrected using: [self.presentingViewController dismissViewControllerAnimated:NO completion:nil]; As show in: http://stackoverflow.com/questions/14907518/modal-view-controllers-how-to-display-and-dismiss – sgb004 Aug 05 '13 at 22:32
  • Can you clarify? That last comment was truncated. – garrettmurray Aug 05 '13 at 22:34
  • Sorry!, the warning is corrected using [self.presentingViewController dismissViewControllerAnimated:NO completion:nil]; As show in: http://stackoverflow.com/questions/14907518/modal-view-controllers-how-to-display-and-dismiss – sgb004 Aug 05 '13 at 22:40