0

I want to display particular ViewController, let say defaultViewController, whenever the user leaves from any ViewController.

So in the didEnterForeground I have added this code,

self.DefaultViewController = [[DefaultViewController alloc] initWithNibName:@"DefaultViewController" bundle:nil];
self.window.rootViewController = _defaultViewController;
[self.window makeKeyAndVisible];

And this works fine, but I want to make sure what I am doing is right. And whether this will result in any memory problem ? as I am not bothering the ViewController which is last used in the didEnterForeGround.

Please !!

Perseus
  • 1,546
  • 4
  • 30
  • 55
  • whether your defaultViewController and viewController loaded in appDidFinishLoading are both same.? – vishy Jul 24 '12 at 06:37

1 Answers1

0

Lets address the scenario in general.

You add a Navigation Controller with some HomeViewController. Then you navigate to other viewController, Tab Bar Controller or whatever. Now whenever user closes the app. You want is, that on the launch, we should display the HomeViewController to him.

Now, if you have a Navigation Controller handling the navigation(it might be hidden to), you can always pop to any view controller available on the stack of Navigation Controller. And that way its easy.

Vaibhav Tekam
  • 2,344
  • 3
  • 18
  • 27
  • What you said is the exact thing I want it to be done. And I am not using the Navigation Controller. I am simply opening the ViewController whenever button is pressed. So The above code which I have added in the didEnterForeground will not be a problem right ? – Perseus Jul 24 '12 at 08:44