如何延迟Default.png?

发布于 2024-08-25 19:05:31 字数 30 浏览 4 评论 0原文

如何延迟应用程序加载以更长时间地显示启动屏幕?

How can I delay the app loading to show the splash screen for longer?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

时光磨忆 2024-09-01 19:05:31

您应该让应用程序照常启动,然后使出现的第一个视图具有与初始屏幕相同的图像。启动计时器,然后在几秒钟后将该视图替换为真实的应用程序根视图。

故意推迟实际的应用程序启动是一个很大的禁忌。

You should let the app start as usual then make the first view that appears have the identical image on it as the splash screen. Start a timer and then replace that view with your real application root view after a few seconds.

Deliberately delaying the actual application launch is a big no-no.

无人问我粥可暖 2024-09-01 19:05:31

更新:不,说真的,不要这样做!

或者我们使用 C 函数

sleep(9);

将其放入 applicationDidFinishLaunching: 将使程序暂停 9 秒,也可以输入任何其他整数。

编辑:在过去的一年里我学到了很多东西。不要这样做。原因是如果启动时间过长,跳板会自动停止应用程序启动。该时间记录很少,因此即使一秒钟也可能导致应用程序失败。

UPDATE: No seriously, DON'T do this!

Or us the C function

sleep(9);

Putting this in applicationDidFinishLaunching: will cause you program to pause for 9 seconds, any other integer may be entered as well.

EDIT: I've learned a lot in the past year. Don't do this. The reason being that the springboard will automatically stop the app launching if it takes too long. That timing is poorly documented so even one second can result in the app failing.

知你几分 2024-09-01 19:05:31

这个问题是类似的: splash screen like tap tap heaven 3

基本上,在您的 applicationDidFinishLaunching: 中,在包含 Default.png 的其他视图之上添加一个图像视图。

This question is similar: splash screen like tap tap revenge 3

Basically, in your applicationDidFinishLaunching:, add an image view on top of other views containing your Default.png.

白鸥掠海 2024-09-01 19:05:31

请参阅上面的讨论,了解为什么您不应该以这种方式延迟应用程序加载。但是,如果您碰巧遇到这样的情况,即短时间睡眠比切换视图的开销更可取,请使用 NSThread 的 sleepForTimeIntervale 而不是 sleep()。它对框架更加友好,并且您可以更精细地控制睡眠时间:

[NSThread sleepForTimeInterval:0.75]

See the above discussion of why you probably should not delay your app load in this way. But if you happen to have a scenario where sleeping for short duration would be preferable to the overhead of switching out a view, use NSThread's sleepForTimeIntervale instead of sleep(). It's more framework friendly and you have more granular control over the sleep time:

[NSThread sleepForTimeInterval:0.75]
心奴独伤 2024-09-01 19:05:31

我遇到过这样的情况:客户必须演示启动图像。所以,这就是我的解决方案..

- (void)applicationDidBecomeActive:(UIApplication *)application

{

UIImageView *defaultImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]];
[self.window addSubview:defaultImageView];
sleep(2);
[defaultImageView removeFromSuperview];
[defaultImageView release];
/*
 Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
 */

}

I had a situation where the client had to demo the launch image. So, this was my solution..

- (void)applicationDidBecomeActive:(UIApplication *)application

{

UIImageView *defaultImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"[email protected]"]];
[self.window addSubview:defaultImageView];
sleep(2);
[defaultImageView removeFromSuperview];
[defaultImageView release];
/*
 Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
 */

}

新一帅帅 2024-09-01 19:05:31

你可以使用它的 sleep 方法来得到这个结果”

睡眠时间间隔

”,如果你想获取它的启动时间,请执行以下操作:

- (void) applicationDidFinishLaunching:(UIApplication*)application
{
   [NSThread sleepForTimeInterval:8.0];
}

它将延迟启动 8 秒

警告:但苹果不推荐这样做,因为它会监视你的应用程序加载时间很长,它会杀死你的应用程序。应用程序。
但是,如果您需要它来获取某些特定的屏幕截图或用于某些内部使用,您可以使用它来解决问题,但永远不要在应用程序提交中使用。

You can use it sleep method to get this result "

sleepForTimeInterval

", If you want to get it launch time, do like :

- (void) applicationDidFinishLaunching:(UIApplication*)application
{
   [NSThread sleepForTimeInterval:8.0];
}

It will delay the launch by 8 seconds

Warning : But it is not recommended by apple, as it will the watchdod about long time for your app loading, It can kill your app.
But incase if you need it to get some specific screenshot or for some in-house use, you can use to solve for purpose but never in app submission.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文