How to make a static image appear after 3 seconds?

4 Solutions Collect From Internet About “How to make a static image appear after 3 seconds?”

You can use:

[self performSelector: withObject: afterDelay: ]

I’m a big fan of using GCD (iOS 4+) because you can simplify your code with inline blocks.

In your case, you should set the image to hidden in Interface Builder, then create an IBOutlet with a connection to an ivar in your class.

Then you can simply run this in viewDidLoad or similar:

dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * 3.0); 
dispatch_after(delay, dispatch_get_main_queue(), ^(void){
    yourImage.hidden = NO;

This assumes that you are calling performSelector:withObject:afterDelay from the main thread, and that your UIImageView is initially hidden.

//assumes theImageView.hidden = YES
[self performSelector:@selector(showImage:) withObject:theImageView afterDelay:yourTimeInterval];

-(void)showImage:(UIImageView*)anImageView {
    anImageView.hidden = NO;

It is important that performSelector is called from the main thread because the selector that is called after the delay will run on the same thread, and you do not want to update UI from anything other than the main thread as a general rule.

I haven’t used XCode in awhile, but I’ll take a stab for ya..

  1. In your Interface Builder set the image’s visibility as hidden

  2. When your app starts up, set some global variable to the current time in an init fxn

  3. In the main control loop for your UI, check if that global var contains a time that is more than 3 seconds ago, if so, change that image’s visibility parameter to shown.

Best I can really say without really taking a look, which isn’t possible right now.

Good luck!