在显示启动画面时从webservice加载数据

时间:2012-08-29 12:34:35

标签: iphone web-services splash-screen

我正在尝试在显示启动画面时从webservices加载一些数据。

我正在尝试使用下面的代码,但我仍然无法找到合适的解决方案。

- (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];
}

2 个答案:

答案 0 :(得分: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];
}

答案 1 :(得分: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];
}