在TabBarController之前加载欢迎屏幕(启动画面)

时间:2010-01-08 16:44:05

标签: ios iphone uiviewcontroller

在我的基于TabBar的iPhone应用程序中,我想在实际应用程序加载之前显示全屏欢迎页面(带有一些日志),如何从xib文件加载UIView作为欢迎屏幕然后从那里我可以加载我的基于TabBar的应用程序。

5 个答案:

答案 0 :(得分:5)

执行此操作的正确方法是正常加载标签栏应用程序,但使用标签栏控制器的presentModalViewController:animated:方法在其上显示视图控制器(在application:didFinishLaunching:中):< / p>

SplashScreenController *controller = [[SplashScreenController alloc] initWithNibNamed:nil bundle:nil];
[self.tabBarController presentModalViewController:controller animated:YES];
[controller release];

我通常会在启动画面上放一个“关闭”按钮,但你也可以这样做:

[self.tabBarController performSelector:@selector(dismissModalViewControllerAnimated:) withObject:YES afterDelay:2.0];

将在启动时显示视图控制器,并在两秒后将其关闭。将YES es更改为NO以避免从底部向上滑动动画。

答案 1 :(得分:3)

我在appDelegate的主窗口中添加了一个subView:

LoginViewController *loginController = [[LoginViewController alloc] initWithNibName:@"LoginViewController"
                                                                             bundle: nil];
[window addSubview: [loginController view]];

然后在LoginViewController中,当我准备关闭View时(显示你的tabController说)我这样做:

UIView *currentView = self.view;
UIView *theWindow = [currentView superview];

[currentView removeFromSuperview];

CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];

答案 2 :(得分:2)

UI指南说你不应该有一个闪屏 - 你应该呈现用户在加载应用程序时会看到的虚拟版本的视图,其中没有任何数据:

请参阅Apple iPhone UI Guidelines on Launch Images了解详情 - 以下是摘录:

  

增强用户的体验   应用程序启动,您应该提供   发射图像。启动图像看起来   非常类似于你的第一个屏幕   应用程序显示iPhone OS   当。时立即显示这个图像   用户点击你的应用程序图标   主屏幕。一旦它准备好了   使用,您的应用程序显示它   第一个屏幕,取代发射   占位符图片。

     

重要的是要强调这一点   提供启动图像的原因是   改善用户体验;它不是   机会提供:

     
      
  • “申请入门体验”   例如闪屏
  •   
  • 关于   窗口
  •   
  • 品牌元素,除非他们   是你的静态部分   应用程序的第一个屏幕
  •   

答案 3 :(得分:2)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{    
    splashView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"image01.png"]];
    splashView.frame=CGRectMake(0,21,320,460);
    [self.window makeKeyAndVisible];
    [self.window addSubview:splashView];


    [self performSelector:@selector(splashremove) withObject:nil afterDelay:10.5];
    [self performSelector:@selector(sixthimage) withObject:nil afterDelay:9.0];
    [self performSelector:@selector(fifthimage) withObject:nil afterDelay:7.5];
    [self performSelector:@selector(fourthimage) withObject:nil afterDelay:6.0];
    [self performSelector:@selector(thirdimage) withObject:nil afterDelay:4.5];
    [self performSelector:@selector(secondimage) withObject:nil afterDelay:3.0];
    [self performSelector:@selector(firstimage) withObject:nil afterDelay:1.5];


   return YES;
}

-(void)firstimage
{
    NSLog(@"Inside first image");
    splashView.image=[UIImage imageNamed:@"image01.png"];
}


-(void)secondimage
{
    NSLog(@"Inside second image");
    splashView.image=[UIImage imageNamed:@"image02.png"];
}



-(void)thirdimage
{
    NSLog(@"Inside third image");
    splashView.image=[UIImage imageNamed:@"image03.png"];
}



-(void)fourthimage
{
    NSLog(@"Inside fourth image");
    splashView.image=[UIImage imageNamed:@"image04.png"];
}



-(void)fifthimage
{
    NSLog(@"Inside fifth image");
    splashView.image=[UIImage imageNamed:@"image05.png"];
}



-(void)sixthimage
{
    NSLog(@"Inside sixth image");
    splashView.image=[UIImage imageNamed:@"image06.png"];


}

-(void)splashremove
{
    NSLog(@"Inside splashremove image");

    [splashView removeFromSuperview];
    [splashView release];

    [self.window addSubview:tabBarController.view];
    [self.window makeKeyAndVisible];

}

答案 4 :(得分:0)

在我的一个标签栏应用中,我会显示如下的启动画面:

在我的app delegate对象中,我开始在didFinishLaunchingWithOptions中显示它

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    splashScreenVC = [[SplashScreenViewController alloc] initWithNibName:@"SplashScreenView" bundle:nil];

    [window addSubview:splashScreenVC.view];
    [window makeKeyAndVisible];

    //set delay before showing new screen
    [NSTimer scheduledTimerWithTimeInterval:1.5f target:self selector:@selector(onSlashScreenExpired:) userInfo:nil repeats:NO];

    return YES;
}

onSlashScreenExpired方法如下所示:

- (void)onSlashScreenExpired:(id)userInfo{
    [splashScreenVC.view removeFromSuperview];
    [splashScreenVC release];

    // At this point, create the tab bar controller and display it
}

我很确定我从另一个关于SO的问题拼凑了这个,但我找不到它。

相关问题