【发布时间】:2013-01-04 01:22:08
【问题描述】:
我的 iOS iPad 应用程序具有以下结构:
- RootViewController:登录
- @property UITabbar *main(登录成功后加载);
在appDelegate 上,我有两个属性:窗口和登录。在第一个我加载UIWindow 和其他LoginViewController (UIViewController)。并将 Login 设置为 RootViewController。
登录时,我有一个名为“main”的属性,类型为MainController(扩展为UITabbarController)。
成功登录后,我使用上面的代码加载main:
[_main setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
[self presentViewController:_main animated:YES completion:nil];
MainController 在 viewDidLoad 方法中加载。我有两点:
我需要将 self 设置为 MainController 的委托?
这是我的 MainController viewDidLoad 方法的开始:
[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]);
这个日志是:
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)
我是否使用正确的方式来呈现 viewController?或者在我单击按钮或登录后显示视图? 缺什么?我是否正确使用了视图层次结构?
是否需要一个属性来包含将要呈现的控制器?
从现在开始我很感激!
【问题讨论】:
标签: objective-c xcode cocoa ios6 parentviewcontroller