Iphone launch image disappear very fast - iphone

The launch image appear and disappear very fast in the iPhone.
How can I control this time? How much seconds is the default?
Thanks

You can use a sleep(time in seconds) function in the application:didFinishLaunchingWithOptions: to explicitly increase some time by yourself.
Eg :
sleep(3);
Will extend the time to 3 more seconds.
Note : As rmaddy said, make user stare at splash screen for a long time is not a good practice. But you can use this in customer's demand.
Happy coding. :)

There's no default — it stays up until your program has been loaded and returned from application:didFinishLaunchingWithOptions:.
If you want to keep the image up under programmatic control then you'll need to place it on screen manually as the first thing the program displays, then dismiss it through the usual channels. This would be relatively easy on a pre-5 iPhone (just put up a big UIImageView with Default.png in it) but as of the iPhone 5 and with the iPad you're going to have to make some sort of decisions about which default screen to show.

You can also try to add a sleep time in your didFinishLaunchingWithOptions method as below:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[NSThread sleepForTimeInterval:3.0f]; //add 3 seconds longer.
//other code....
}

Related

increase launch image time on xcode

for iOS devices, after set a custom launch time image, when tested on simulator it remains about 4s but when tested on iphone it is hide after less than 1s! Assumed that depends on processor but how to modify that visualization time?? Thanks.
Better option would be to put a sleep of 5 seconds in your appDidFinishLaunching: method.
Statement at the start of your appDidFinishLaunching: method.
sleep(5);
Hope this helps you.
Note:- You may want to increase the time from 5 seconds to whatever time that is suitable for you. Thanks
EDIT: You may need to include #import <unistd.h> statement.
We can also increase the duration time of App Launch Image by implement applicationShouldLaunch as below,
#import "MSTRMobileAppDelegate.h
#implementation MSTRMobileAppDelegate (Extension)
- (BOOL)applicationShouldLaunch:(UIApplication *)application errorDescription:(NSString**)errorString
{
sleep(10);
return TRUE;
}
#end`
You can't actually change of the loading time itself - that's decided by the operating system and how it takes to load.
BUT - you can make it feel like it takes longer by simply putting a UIImageView with your image on top of your main window application and removing it using an NSTimer - you can even use nicer animations to make it disappear like make it fade out.
Add the sleep function to your this method below in your delegate class.
NOTE: the name of the method is NOT the same as suggested in the answers above.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
sleep(3); //PUT THE SLEEP HERE AND IT WILL HOLD YOUR LAUNCH IMAGE FOR HOWEVER SECONDS YOU "SLEEP"
// Override point for customization after application launch.
return YES;
}
This worked for me. This post is intended for future seekers to this problem not that I'm trying to answer a question that was asked 2 years ago

Animation/Video as launch images ios

Does anyone know if it's possible to show a video or an animation instead of a regular launch image in ios? The app's like D&G and Mango did this but I can't seem to find how. Is this maybe not an actual launch images, but a video which in triggered in the didfinishlauncingwithoptions.
Thnx!
Wel after the app hit the - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions you can setup an animation.
There is no way to do this before this point.
The os just looks for the Default.png in the bundle and displays it als long as your app is starting up. (read not returned from the above mentions method).

Dynamically calculate application load time

How can I run a clock that allows me to measure the time to load until appDidFinishLaunching ?
I want to set a sleep call that extends the Defaul.png show time to 3 seconds regardless the speed of the underlying hardware.
First off, you should know that Springboard in iPhone OS is kinda picky about load times. You should never make a sleep call somewhere in the loading process of you application. If Springboard detects that your application is taking too long to launch, your application will be terminated with "failed to launch in time" in the crash log.
Secondly, there is no, as far as I know, way of measuring the time your application took to launch. There are several thing happening when the user taps the Application icon on the springboard, and the iPhone OS provides no good information to your application.
One solution could be to make sure your applicationDidFinishLaunching: is very lightweight, and creating a "fake" Default.png overlay. By trimming down your applicationDidFinishLaunching: method to do only the most essential stuff, and the performing any time consuming tasks in the background, you can ensure that your Default.png overlay is displayed roughly the same time on different hardware.
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Create the image view posing with default.png on top of the application
UIImageView *defaultPNG = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"Default.png"]];
// Add the image view top-most in the window
[window addSubview:defaultPNG];
[window makeKeyAndVisible];
// Begin doing the time consuming stuff in the background
[self performSelectorInBackground:#selector(loadStuff) withObject:nil];
// Remove the default.png after 3 seconds
[self performSelector:#selector(removeDefaultPNG:) withObject:defaultPNG afterDelay:3.0f];
}
- (void)removeDefaultPNG:(UIImageView *)defaultPNG {
// We're now assuming that the application is loaded underneath the defaultPNG overlay
// This might not be the case, so you can also check here to see if it's ok to remove the overlay
[defaultPNG removeFromSuperview];
[defaultPNG release];
}
If you add more views (your view controllers etc) in the loadStuff method, you should insert them below the defaultPNG overlay. You should also be aware of problems that could occur by doing these things from another thread. You could use performSelectorOnMainThread:withObject:waitUntilDone: if you encounter problems.

How to delay Default.png?

How can I delay the app loading to show the splash screen for longer?
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.
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.

Awake from sleep event on the iPhone?

Is there any way to detect if the iPhone wakes up from sleep while you're app is running? Eg: your app is running, the user locks the screen (or the screen auto locks) and some time later the user unlocks the screen and up pops your app. Is there some way to get an event at that point or detect it somehow?
I've tried searching the Google and this forum, but I can't seem to find anything about it.
See applicationDidBecomeActive: on UIApplicationDelegate.
Stick these in you AppDelegate.m file:
-(void) applicationWillResignActive:(UIApplication *)application {
NSLog(#"Asleep");
}
-(void) applicationDidBecomeActive:(UIApplication *)application {
NSLog(#"Awake");
}
#Kevin - Nothing wrong with your answer - thanks by the way. Just thought I'd save the next person a Google search.