应用程序卡在iOS 9上的启动画面中,没有错误 [英] App stuck in splash screen on iOS 9 with no error
问题描述
我的应用程序在iPhone和模拟器上都停留在iOS 9的启动画面上。我可以在iOS 8或更低版本的设备和模拟器上运行它没有问题。我在同一个应用程序上工作的同事有完全相同的问题。
My app gets stuck on splash screen in iOS 9 both on iPhone and simulator. I can run it on iOS 8 or lower on device and simulator with no problem. My colleague working on the same app has exactly the same problem.
没有任何错误或任何错误,只需在启动画面上挂起即可。如果我在xcode上停止它并尝试直接从手机或模拟器运行它,它将运行没有任何问题。
There is no error or anything, just hangs on splash screen. If I stop it on xcode and try to run it from the phone or simulator directly, it would run without any problem.
顺便说一句,我没有看到 didFinishLaunchingWithOptions
或 willFinishLaunchingWithOptions
被叫!
By the way, I don't see didFinishLaunchingWithOptions
or willFinishLaunchingWithOptions
getting called!
推荐答案
在回答中包含代码:
+(void)initialize
{
titles = @[NSLocalizedString(@"CODE", nil), NSLocalizedString(@"ERROR", nil), NSLocalizedString(@"TROUBLESHOOTING", nil)];
}
这确实是您问题的根源。在实施 + load
或 + initialize
时要非常小心。 @bbum 一篇很棒的文章。
This is indeed the source of your issue. It's wise to be very careful when implementing +load
or +initialize
. @bbum has a great article on exactly that topic.
+ initialize
是第一次被调用触及类(或类别) - 初始化类时,类加载机制调用 + initialize
。无法保证在类加载过程中何时可能发生这种情况,这是您问题的一部分。
+initialize
is invoked the first time the class (or category) is touched - when the class is initialized +initialize
is called by the class loading mechanism. There is no guarantee of when in the class loading process this may happen, which is part of your problem.
在您的情况下,您使用的是 NSLocalizedString
- 引擎盖下可能相当沉重。它依赖于其他几个类( NSString
等)并可能访问文件系统。正如@bbum在他的文章中指出的那样,这可能会导致严重的麻烦。在你的情况下,这可能是一个令人讨厌的僵局。
In your case you are using NSLocalizedString
- which under the hood can be fairly heavy. It has dependancies on several other classes (NSString
, etc) and can potentially access the file system. As @bbum points out in his article, that can lead to serious trouble. In your case, this may be a nasty deadlock.
移动你的 titles = @ [NSLocalizedString ...
行在你的对象中一个更合适的位置,比如初始化器,awakeAfterUsingCoder:等等,你应该解决你的问题。执行此操作后,您应检查整个代码库中是否有 + initialize
和 + load
的实例,并审核它们以进行制作确定这些用途符合@bbum的建议。
Move your titles = @[NSLocalizedString...
line to a more appropriate place in your object, like an initializer, awakeAfterUsingCoder:, etc. and your immediate problem should be solved. After doing so you should check your entire codebase for instances where +initialize
and +load
are implemented and audit them to make sure those uses are in line with @bbum 's recommendations.
这篇关于应用程序卡在iOS 9上的启动画面中,没有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!