升级到iOS 4.2后,应用程序在启动时显示白屏 [英] App shows white screen on startup after upgrading to iOS 4.2

查看:159
本文介绍了升级到iOS 4.2后,应用程序在启动时显示白屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几周中,我一直在开发一个使用SoundManager类的应用程序,该类是通过此博客文章的评论找到的: http://www.gehacktes. net/2009/03/iphone-programming-part-6-multi-sounds-with-openal/

For the past few weeks I have been working on an app that uses a SoundManager class that I found via the comments of this blog post: http://www.gehacktes.net/2009/03/iphone-programming-part-6-multiple-sounds-with-openal/

David Evans的评论中提供了指向SoundManager和测试器应用程序的链接.我不允许提供第二个链接,因此我将提及他链接到的ZIP文件的名称: SoundTester.zip

The link to the SoundManager and tester app is provided in the comments by David Evans. I am not allowed to provide a second link so I'll mention the name of ZIP file he links to: SoundTester.zip

在iOS 4.2发布之前,我对这段代码感到非常满意.相应地更新了iPad和Xcode之后,使用SoundManager类的应用仅显示带有标题的导航栏.屏幕的其余部分为白色.这不是iPad的特定行为.我已经在升级到iOS 4.2的iPhone4和iPhone 3G上看到了相同的内容.

I was very happy with this code, until iOS 4.2 was released. After updating my iPad and Xcode correspondingly, my apps that use the SoundManager class only show the navigation bar with it's title. The rest of the screen is white. It's not iPad specific behavior. I have seen the same on an iPhone4 and an iPhone 3G that upgraded to iOS 4.2.

在模拟器中运行应用程序时,我得到相同的结果.问题是在控制台窗口中没有错误消息,也没有构建和编译错误.对于几个月前才开始使用iPhone SDK的iPhone开发人员来说,这非常令人沮丧,而且很难修复.

When running the apps in the simulator, I get the same results. The problem is that I get no error messages in the console window and no build and compile errors at all. Very frustrating and very hard to fix for an iPhone developer that started using the iPhone SDK only months ago.

有人知道什么可能坏掉了,如何解决?感谢您的帮助!

Does anyone have a clue what could have gone broken and how to fix it? Any help is appreciated!

推荐答案

有人请枪杀我...

在我从《 iPhone开发者手册》中写下的一段代码的帮助下,才发现问题所在.

Just found the problem, with the help from a piece of code I had written down from the iPhone Developer's Cookbook.

问题不是SoundManager(幸运的是,它仍然可以正常工作),而是在App Delegate类的application:didFinishLaunchingWithOptions:方法中.

The problem was not the SoundManager (which still works fine, fortunately!) but in the application:didFinishLaunchingWithOptions: method in the App Delegate class.

以下是在iOS 4.2中引起问题的代码,但仍在iOS 3.2中有效:

Here is the code that causes the problem in iOS 4.2 but still works in iOS 3.2:

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

// Create a Navigation Controller on the fly.
// Use the View Controller as root view controller.
viewController.title = @"ThreeSounds";

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
nav.navigationBar.barStyle = UIBarStyleBlack;

// Add the view controller's view to the window and display.
[window addSubview:nav.view];
[nav release];

[window makeKeyAndVisible];

return YES;
} 

解决方案:删除以下行:[nav release]. 由于某些原因,释放导航控制器在iOS 3.2中不是问题. 在iOS 4.2中,屏幕变白了.

The solution: remove the line that says: [nav release]. For some reason, releasing the navigation controller was not a problem in iOS 3.2. In iOS 4.2 is makes the screen go white.

我发现此方法是问题所在,因为它是最后执行的方法.反过来,我通过将这段代码添加到项目中的每个类中来找出答案:

I found out that this method was the problem because it was the last method that was executed. That, in turn, I found out by adding this piece of code to every class in my project:

-(BOOL) respondsToSelector:(SEL)aSelector {
 printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]);
 return [super respondsToSelector:aSelector];
}

这段代码记录了所有被调用的方法.

This piece of code logs all the methods that get called.

这篇关于升级到iOS 4.2后,应用程序在启动时显示白屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆