【发布时间】:2010-07-28 13:58:25
【问题描述】:
下面的代码试图实现一个方法,让我的导航控制器启动到两个不同视图中的一个。问题是每当我的应用程序启动时,我总是会出现黑屏。
#import "SugarCRMReleaseOneAppDelegate.h"
#import "SettingsViewController.h"
#import "ModuleViewController.h"
@implementation SugarCRMReleaseOneAppDelegate
@synthesize window;
@synthesize navigationController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch
NSString *a2 = [[NSString alloc] init];
a2 = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedUsername"];
NSString *b2 = [[NSString alloc] init];
b2 = [[NSUserDefaults standardUserDefaults] objectForKey:@"savedPassword"];
[window makeKeyAndVisible];
if(a2 == nil && b2 == nil) {
SettingsViewController *viewController1 = [[SettingsViewController alloc] initWithNibName:@"SettingsViewController" bundle:nil];
[navigationController initWithRootViewController:viewController1];
[window addSubview:[navigationController view]];
[viewController1 release];
}
else {
ModuleViewController *viewController2 = [[ModuleViewController alloc] initWithNibName:@"ModuleViewController" bundle:nil];
[navigationController initWithRootViewController:viewController2];
[window addSubview:[navigationController view]];
[viewController2 release];
}
[UIApplication sharedApplication].idleTimerDisabled=YES;
return YES;
}
【问题讨论】:
标签: iphone objective-c uiview uinavigationcontroller delegates