我想知道如何在第一次启动应用程序时显示页面,我为这些代码提供了serch,并获得了许多代码,但在我的情况下,它并不适合我,我在DidFinishLaunching方法中使用此代码,如何在首次启动应用程序时显示UIViewController?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],@"firstLaunch",nil]];
//If First Launch
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]) {
//Show help view
UIScrollView_PagingViewController *detailViewController = [[UIScrollView_PagingViewController alloc] initWithNibName:@"UIScrollView_PagingViewController" bundle:nil];
//detailViewController.firstString = firstString;
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
else {
NSError *error = nil;
NSString *username = [[NSUserDefaults standardUserDefaults] objectForKey:@"username"];
NSString *str = [SFHFKeychainUtils getPasswordForUsername:username andServiceName:@"mybibleapp" error:&error];
NSLog(@"previous user");
NSLog(@"%@", str);
if (!error && nil != str)
{
ParallelReadViewController *detailViewController = [[ParallelReadViewController alloc] initWithNibName:@"ParallelReadViewController" bundle:nil];
//detailViewController.firstString = firstString;
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
else
{
RootViewController *detailViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
//detailViewController.firstString = firstString;
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
}
但是当我运行这段代码时,它显示一个空白的白色屏幕,没有任何显示。
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],@"firstLaunch",nil]];
//If First Launch
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]) {
//Show help view
UIScrollView_PagingViewController *detailViewController = [[UIScrollView_PagingViewController alloc] initWithNibName:@"UIScrollView_PagingViewController" bundle:nil];
//detailViewController.firstString = firstString;
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
else {
我把上面的代码发射升空UIScrollView_PagingViewController推出。但没有luck.What是我在上面code.?.please所犯的错误,帮助我。 在此先感谢。