简体   繁体   English

在App推出时添加启动画面(即使是多任务处理)?

[英]Add Splash-screen for when App Launches (Even From Multitasking)?

I need to add a short splash-screen to my app, which appears even when the app is launched from multitasking. 我需要在我的应用程序中添加一个简短的启动画面,即使应用程序是从多任务处理启动时也会出现。

I have managed to do so, popping an UIImageView up and fading it out after a couple of seconds form the - (void)applicationWillEnterForeground:(UIApplication *)application method in my app delegate. 我已经设法这样做了,在我的应用程序委托中形成- (void)applicationWillEnterForeground:(UIApplication *)application方法后,弹出一个UIImageView并将其淡出。

However when launching from multitasking, while it appears and works fairly well, sometimes there a short delay before the image pops up and so you briefly see the view behind it. 但是,当从多任务处理启动时,虽然它看起来并且工作得相当好,但有时会在图像弹出之前出现短暂的延迟,因此您可以短暂地看到它背后的视图。

How can I overcome this? 我怎么能克服这个?

Thanks. 谢谢。

ok, now I understand - 好的,现在我明白了 -

then you may try to use 然后你可以尝试使用

 - (void)applicationDidBecomeActive:(UIApplication *)application

If I understand correctly you're just trying to create a launch image right? 如果我理解正确,您只是想创建一个启动图像吗? So in that case you would simply go into your info-plist in Supporting Files then highlight one of the items and press the "+" icon. 因此,在这种情况下,您只需进入支持文件中的信息播放器,然后突出显示其中一个项目并按“+”图标。 Select "Launch Image" from the drag down menu, and type the name of your image into the text box next to "Launch Image". 从下拉菜单中选择“启动图像”,然后在“启动图像”旁边的文本框中键入图像的名称。

Try this. 尝试这个。

Create a reference (a strong reference if using ARC) to the view, so you hold it. 在视图中创建一个引用(如果使用ARC,则为强引用),因此您可以保留它。 Then create the view anywhere in the program really (I guess at first start would be good). 然后真正在程序中的任何地方创建视图(我想首先开始会很好)。 Then, when you return from multitasking, you don't need to create a new view (which might take time), you only push the view that you already have set up in-memory. 然后,当您从多任务处理返回时,您不需要创建新视图(这可能需要一些时间),您只需按下已在内存中设置的视图。

Assuming you don't do this already, it should significantly shorten (or remove) the delay you're seeing. 假设你没有这样做,它应该会显着缩短(或消除)你所看到的延迟。

Also, don't forget to set animated: to NO 另外,不要忘记将animated:设置为NO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM