我試圖做一些事情很容易,我估計:爲什麼我無法從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