0

I have the following structure on my iOS iPad app:

  • RootViewController: Login
    • @property UITabbar *main (which is loaded after login with success);

On appDelegate I have two properties: window and login. On the first one I load the UIWindow and on other LoginViewController (UIViewController). And set Login as RootViewController.

On Login I have a property named "main" typed as MainController (extends UITabbarController).

After the successfull login I use the code above to load main:

[_main setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:_main animated:YES completion:nil];

MainController was loaded in the viewDidLoad method. I have two points:

I need to set self as delegate of MainController?

This is the begin of my MainController viewDidLoad method:

[super viewDidLoad];
[self setDelegate:self];
NSLog(@"Parent view controller is: %@", [self parentViewController]);
NSLog(@"Presented view controller is: %@", [self presentedViewController]);
NSLog(@"Presenting view controller is: %@", [self presentingViewController]);

The log of this is:

2013-01-20 21:23:53.180 MyApp[6304:11303] Parent view controller is: (null)
2013-01-20 21:23:53.181 MyApp[6304:11303] Presented view controller is: (null)
2013-01-20 21:23:53.182 MyApp[6304:11303] Presenting view controller is: (null)

Am I using the correct way to present a viewController? Or to show a view after I click on a button or login? What is missing? Am I using correctly the view hierarchy?

Exists the need of a property to contain the controller which will be presented?

I appreciate since now!

1 Answers1

0

Did you write the code for the app delegate and and the other controllers yourself? If that's the case then because you haven't posted the rest of your code all I can say is to initialize all your view controllers.

YourViewControllerNameHere = [[ViewControllerType alloc] init];

or if you have a nib/xib/storyboard file then

    YourViewControllerNameHere = [[ViewControllerType alloc] initWithNibName:youInterfaceFileNameHereWithoutFileType bundle:nil];
Alex
  • 1,388
  • 1
  • 10
  • 19
  • Alex, i was initialized them. They are correctly loading and appearing, they just haven`t a parentViewController defined when they`re running. – Káliman Borges Jan 22 '13 at 17:57