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!

4

1 回答 1

0

您是否自己编写了应用程序委托和其他控制器的代码?如果是这种情况,那么因为您还没有发布其余代码,所以我只能说初始化所有视图控制器。

YourViewControllerNameHere = [[ViewControllerType alloc] init];

或者如果你有一个 nib/xib/storyboard 文件,那么

    YourViewControllerNameHere = [[ViewControllerType alloc] initWithNibName:youInterfaceFileNameHereWithoutFileType bundle:nil];
于 2013-01-21T04:27:42.530 回答