How to delay Default.png?

跟風遠走 提交于 2019-11-30 08:54:50

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.

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.

Ben Gottlieb

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.

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]

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:@"Default@2x.png"]];
[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.
 */

}

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!