我正在尝试在显示启动屏幕时从网络服务加载一些数据。
我正在尝试使用下面的代码来实现这一点,但我仍然无法找到合适的解决方案。
- (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];
}
最佳答案
如果您想显示启动屏幕,只需将名为“default.png”的图像文件放入资源中即可。该应用程序将在启动时在加载任何 View 之前自动显示该内容。并在 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];
}
关于iphone - 显示闪屏时从 Web 服务加载数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12178091/