更改iPhone启动画面时间

iOS*_*per 7 iphone xcode splash-screen ios

例如,如何让启动画面停留更长时间,持续5秒?

Dha*_*ara 33

sleep(5.0)在你的

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法.

  • 不要这样做.很坏. (6认同)

Hel*_*miB 10

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

  /*this will pause main thread for x interval seconds. 
  put on the top of application:didFinishLaunchingWithOptions, so it will not 
  proceed to show window until sleep interval is finished.*/

    [NSThread sleepForTimeInterval:5]; //add 5 seconds longer.
   //other code....
}
Run Code Online (Sandbox Code Playgroud)

  • 不要这样做.很坏. (4认同)

iam*_*ult 9

您需要创建一个视图控制器来显示启动屏幕,如下所示.

   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [self generateRandomSplashScreen];

        [self performSelector:@selector(removeSplashScreen) withObject:nil afterDelay:SPLASHSCREEN_DELAY];

    [self otherViewControllerLoad]; // the other view controller

        [self.window makeKeyAndVisible];
        return YES;
    }
    -(void) generateRandomSplashScreen
    {
        splashScreenViewController = [[SplashScreenController alloc] initWithNibName:@"SplashScreenController" bundle:[NSBundle mainBundle]];

        [self.window addSubview:self.splashScreenViewController.view];
    }

    -(void) removeSplashScreen
    {
        [splashScreenViewController.view removeFromSuperview];
        self.window.rootViewController = self.tabBarController;
        [splashScreenViewController release];
    }
Run Code Online (Sandbox Code Playgroud)