如果想让一个APP加上引导页面是一个非常完美的举动
但是,总会遇到一些问题
(不要忘记在APDelegate里面加上用户引导页面的头文件和程序启动时的第一个页面哦)
情况一:纯代码
判断是否是第一次启动应用程序
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]] ;
    if(![[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"])
    {
         [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
        NSLog(@"第一次启动");
    //如果是第一次启动的话,使用UserGuideViewController (用户引导页面) 作为根视图
     UserGuideViewController *userGuideViewController = [[UserGuideViewController alloc] init];
     self.window.rootViewController = userGuideViewController;
    }
    else
    {
       NSLog(@"不是第一次启动");
TranslateController *tranVC = [[TranslateController alloc] init];
           self.window.rootViewController = tranVC;
     }
         self.window.backgroundColor = [UIColor whiteColor];
         [self.window makeKeyAndVisible];
    return YES;
}
情况二:使用storyboard
情况基本相同,不同的是
 NSLog(@"不是第一次启动");
        UIStoryboard *story = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
        UIViewController * vc = [story instantiateViewControllerWithIdentifier:@"TranslateController"];
        self.window.rootViewController = vc;
解释一下原理先,如果使用纯代码的话,不是第一次启动应用程序的时候会自动执行下面的代码,所以不会有问题
如果使用storyboard的话,初始化第一个视图控制器(程序第一个界面),什么都没有,(除非你自己使用代码添加控件),而且storyboard在启动的时候并不是从这里开始的,而是默认storyboard的第一个视图控制器,所以,加上一个标志就好

这样它就能找到应该启动的界面