2012-08-29 54 views
2

我想在显示启动画面时从Web服务加载一些数据。在显示启动画面时从webservice加载数据

我想使用下面的代码,但我仍然无法达到合适的解决方案。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    [self backgroundtask]; 
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]   autorelease]; 
    splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; 
    splashView.image = [UIImage imageNamed:@"Default.png"]; 
    [self.window addSubview:splashView]; 
    [self.window bringSubviewToFront:splashView]; 

    ViewController *masterViewController = [[[ViewController alloc]   initWithNibName:@"ViewController" bundle:nil] autorelease]; 
    self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease]; 
    self.window.rootViewController = self.navigationController; 
    [self.window makeKeyAndVisible]; 
} 
+0

使用上述代码有什么错?它不起作用吗?如果有性能问题。你用仪器测量过吗? – 0x8badf00d

回答

1

如果你想显示启动画面只是把名为“为Default.png”到资源的图像文件。在任何视图加载之前,该应用程序会在启动时自动显示。并已在didFinishLaunchingWithOptions有你的代码的其余部分

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
[self backgroundtask]; 
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]   autorelease]; 


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

这样做:

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

    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]   autorelease]; 
    //No need of splash View as u add Default.png to bundle and application will autimatically take it as Launch Image 
    [self backgroundtask]; 
    ViewController *masterViewController = [[[ViewController alloc]   initWithNibName:@"ViewController" bundle:nil] autorelease]; 
    self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease]; 
    self.window.rootViewController = self.navigationController; 
    [self.window makeKeyAndVisible]; 
} 
相关问题