欢迎界面停留2秒后进入主程序界面
直接在欢迎界面的viewDidLoad中使用如下方法即可。
[self performSelector:@selector(GoToViewController) withObject:nil afterDelay:2]; //2秒后,进入应用程序的主界面
在GoToViewController 方法中写如下代码:
-(void)GoToViewController
{
MainViewController *myMainViewController = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil];
[self.view addSubview:myMainViewController.view];
}
如果为欢迎页面增加淡入淡出效果,则将 GoToViewController 方法修改如下:
-(void)GoToViewController { CATransition *animation = [CATransition animation]; animation.delegate = self; animation.duration = 0.7 ; // 动画持续时间(秒) animation.timingFunction = UIViewAnimationCurveEaseInOut; animation.type = kCATransitionFade;//淡入淡出效果 [[self.view layer]addAnimation:animation forKey:@"animation"]; MainViewController *myMainViewController = [[MainViewController alloc]initWithNibName:@"MainViewController" bundle:nil]; [self.view addSubview:myMainViewController.view]; }