Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Futhark

macrumors 65816
Original poster
Jun 12, 2011
1,238
179
Northern Ireland
I've just started working with objective-c and Xcode so I've a lot of learning and probably questions ahead of me :)

My first question is this, I have a loading image that comes up before my app starts, unfortunately it is there for less than a second so you have barely time to see the image and read the text. How can I lengthen the time it stays on screen for?

Many Thanks in advance



---
I am here: http://maps.google.com/maps?ll=54.846420,-6.297348
 
You can't directly control the time for which that first image is displayed. It is just while the app is loading. Once the app has loaded, the app's first view is put on the screen in it's place. So you'll probably need to make your app's view be a view will that image in it, then use an NSTimer to trigger code that moves the app from the image view to an actual functional view.

BTW Making a user wait to use your app is bad UX. The whole point of that first image is to give the illusion of instant-on apps.
 
You can use: [NSThread sleepForTimeInterval: 3.0], where 3.0 is the amount of time you want the splash screen to show. But as jiminaus said, showing the splash screen for longer than necessary can be very frustrating for the user. Also, putting a thread to sleep is not the safest thing to do.
 
Don't sleep your threads, that's not the right approach my opinion.
Rather do something like this ->


Code:
-(void)fadeOut:(UIView*)viewToDissolve withDuration:(NSTimeInterval)duration   andWait:(NSTimeInterval)wait
{
	[UIView beginAnimations: @"Fade Out" context:nil];
	
	// wait for time before begin
	[UIView setAnimationDelay:wait];
	
	// druation of animation
	[UIView setAnimationDuration:duration];
	viewToDissolve.alpha = 0.0;
	[UIView commitAnimations];
}

-(void)fadeIn:(UIView*)viewToFadeIn withDuration:(NSTimeInterval)duration 	  andWait:(NSTimeInterval)wait
{
	[UIView beginAnimations: @"Fade In" context:nil];
	
	// wait for time before begin
	[UIView setAnimationDelay:wait];
    
    // druation of animation
	[UIView setAnimationDuration:duration];
	viewToFadeIn.alpha = 1;
	[UIView commitAnimations];
	
}

/**
 Fade in from fade out
 */
-(void) fadeInFromFadeOut: (UIView*)viewToFadeIn withDuration:(NSTimeInterval)duration
{
	viewToFadeIn.hidden=NO;
    
	[self fadeOut:viewToFadeIn withDuration:1 andWait:0];
	[self fadeIn:viewToFadeIn withDuration:duration andWait:0];

}


Put that in a .M file.
Then just in the viewDidload, call this ->

Code:
    [self fadeInFromFadeOut:logo1 withDuration:4];	
    [self fadeInFromFadeOut:logo2 withDuration:4];	
    [self fadeInFromFadeOut:logo3 withDuration:4];

logo1,logo2,logo3 are UIImageViews (which inherits from UIView), so you can use those in the methods :)
 
You put it in the application: didFinishLaunchingWithOptions: method of your AppDelegate.

I am not sure that's the best approach. Set a flag in application:didFinishLaunchingWithOptions: and then start the animation in applicationDidBecomeActive: if the flag is on.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.