我试图做一些事情很容易,我估计:为什么我无法从didFinishLaunchingWithOptions启动此模式视图?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
prefs = [NSUserDefaults standardUserDefaults];
BOOL IsLoggedIn = [prefs boolForKey:@"IsLoggedIn"];
if(IsLoggedIn == NO)
{
//Show login controller
LoginViewController *lvc = [[LoginViewController alloc] initWithNibName:nil bundle:nil];
[self.tabBarController presentModalViewController:lvc animated:NO];
[lvc release];
}
else if(IsLoggedIn == YES)
{
//Continue doing crap
}
// Override point for customization after application launch.
// Add the tab bar controller's current view as a subview of the window
self.window.rootViewController = self.tabBarController;
NSArray *tabs = self.tabBarController.viewControllers;
UIViewController *tbInvoice = [tabs objectAtIndex:0];
tbInvoice.tabBarItem.image = [UIImage imageNamed:@"Open-Mail.png"];
UIViewController *tbClient = [tabs objectAtIndex:1];
tbClient.tabBarItem.image = [UIImage imageNamed:@"Breifcase.png"];
[self.window makeKeyAndVisible];
return YES;
}
在使用调试器,我看到它进入if(IsLoggedIn == NO)
和运行LoginViewController
码,但鉴于从未显示。
这让我疯狂。
我试着在[self.windoow makeKeyAndVisible]
之后运行代码,但它没有改变任何东西。
此代码看起来像我见过的每个示例。任何人都可以看到我做错了什么?
由于提前,
克里夫
你在哪里初始化的tabBarController? – drewag 2011-03-22 02:03:14
“LoginViewController”如何加载其视图?你为nib名称传递'nil',所以你必须重写'loadView'以编程方式加载视图才能工作。如果是这样,你是否在'loadView'中调用'setView:'(或者如果使用点语法来执行'self.view = whatever')? – jlehr 2011-03-22 03:00:34
@jlehr如果您使用nil作为笔尖名称,它将首先尝试使用与该类名称相同的笔尖。仍然似乎是它会更好指定它,虽然 – drewag 2011-03-22 03:32:47