关于在加载根导航控制器之前显示启动画面:在加载根导航控制器之前显示启动画面 – iPhone

Display a Splash Screen Before Loading the Root Navigation Controller - iPhone

我是 iPhone 的新手。在加载 UIViewController 之前,我已经使用了一些教程,即启动画面。现在我想在我的应用程序中实现一个 NavigationController 并希望在它之前显示一个启动画面。由于我是 Iphone 新手,所以在加载根导航控制器之前,我没有获得任何教程或指南来制作启动画面。

我见过许多覆盖 Default.png 文件的方法等等。我不想实现那个。我想要一个单独的 UIView 在其中包含我的自定义图像和文本,并将该 UI 视图显示为启动画面

谁能指导我。

提前致谢


使用"self.window"首先显示启动图像。如果你简单地写"窗口",图像将不会在第一个视图中显示和动画,因为在这种情况下图像不能直接链接到窗口。在 appdelegate.m

中编写以下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions        
    {
           self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.

        MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];
        self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
        self.window.rootViewController = self.navigationController;
        [self.window makeKeyAndVisible];

        UIImageView *imgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"themes.png"]];
        imgv.userInteractionEnabled = YES;
        [self.navigationController.view addSubview:imgv];
        //[imgv release]; If you don't use ARC, uncomment this.

        [self performSelector:@selector(removeSplash:) withObject:imgv afterDelay:3.0];
        [self.window addSubview:self.navigationController.view];

        return YES;
    }

- (void)removeSplash:(UIImageView *)imageView
  {
       [imageView removeFromSuperview];
  }

给你,伙计。玩得开心愉快的编码....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Add a splash screen
    UIImageView *imgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"splash.png"]];
    imgv.userInteractionEnabled = YES;
    [navigationController.view addSubview:imgv];
    [imgv release];

    [self performSelector:@selector(removeSplash:) withObject:imgv afterDelay:3.0];

    [window addSubview:navigationController.view];
    return YES;
}



- (void)removeSplash:(UIImageView *)imageView {
    [imageView removeFromSuperview];
}