我的应用程序中出现了一个奇怪的问题,在加载启动画面之前它会显示黑屏一段时间。这个黑屏不是由于任何正在进行的操作造成的,因为我首先加载启动画面,然后开始 xml 解析任务。
我什至尝试使用[window makeKeyAndVisible];,但没有成功。
这是我的代码:
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
comingFromLogin = NO;
//Check For Internet
gotInternet = [self checkInternet]; //Test for Internet, calling the self method
if ( gotInternet == 0)
{
//I have no internet
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sorry No Network Available" message:nil delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
// internetIcon.hidden = NO;
}
else
{
//I do have internet
[self didLoadSplashScreen];
}
}
-(void)didLoadSplashScreen
{
activity_indicator = [[ActivityIndicator alloc]initWithNibName:@"ActivityIndicator" bundle:nil];
splashScreen = [[splashScreenView alloc]initWithNibName:@"splashScreenView" bundle:nil];
splashScreen.view.alpha = 1.0;
splashScreen.view.frame = CGRectMake(0, 20, 320, 480);
[window addSubview:splashScreen.view];
[window addSubview:activity_indicator.view];
[window makeKeyAndVisible];
[self disappearSplashScreen];
}
有人可以帮忙吗?
黑屏持续约 2 秒。我在 iOS4 上运行它。
提前致谢。
最佳答案
这是默认的加载行为!在应用程序完成加载之前,applicationDidFinishLaunching
方法不会运行。
克服这个问题的方法是使用 View 大小的图片并将其命名为Default.png
,它将显示而不是黑屏。
关于iphone - 在我的闪屏加载 iPhone 之前出现黑屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3759585/