我的项目中有一个启动画面。我在启动图像中添加了图像,它工作正常。但是我需要添加延迟时间只有2秒,而且我触摸启动画面它会转到主页。
答案 0 :(得分:-1)
您需要创建自己的启动画面,以增强启动画面的持续时间,即创建带有启动画面的控制器并使用计时器关闭它或者您可以这样做
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Don't use this as its risky as per one of the comment
[NSThread sleepForTimeInterval:4.0];
// This will stop further execution and your splash screen would last for 4 extra seconds.
splashScreen = [[UIViewController alloc] initWithNibName:@"SplashView" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:splashScreen];
[window.rootViewController presentModalViewController:navController animated:NO];
}
现在在SplashViewController中
-(IBAction)btnLoadScreenTapped:(id)sender{ //This is button touchup inside method we will load main interface from here
MainViewController *viewController = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil];
[self.navigationController pushViewController:viewController];
}
注意强>
根据评论[NSThread sleepForTimeInterval:4.0];
之一,使用此方法存在风险,请不要使用。像你已经做的那样去寻找上面的代码。