Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

iPhone SDK Tutorial: Make Something Happen After a Delay in Seconds

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
2,033
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Dec 18, 2010

This tutorial shows you how to make some text in a UILabel appear on the screen after a delay in seconds! This is a very cool and useful tutorial! If you guys like it, please subscribe!

Follow Me on Twitter:
http://www.twitter.com/NatesiPhone

Website:
http://www.halfpeeledapple.com

  • likes, 1 dislikes

Link to this comment:

Share to:

Uploader Comments (XcodeDev)

  • The most annoying thing is when you are trying to pause a video by clicking the video (which is what most people do) but instead of pausing the video, it redirects you to your channel forcing me to go back to the video and try to figure out where I was in the video before.

  • @MGuniverse You can turn off annotations. 

Top Comments

  • keep them coming! 

see all

All Comments (15)

Sign In or Sign Up now to post a comment!
  • in my app I've got a delay ,after 30 seconds its shows an alert but if the player collides with an object i'd like to deactivate the delay... any idea?

  • @snipermaniac365 i finally got it!!!! after hours and thinking it makes perfect sense now! thank you so much for your help and the link above!!!! i made 2 voids. one called yellowChange and another called blackChange. Then i used the delay code instead of a NSTimer and made it refer to the yellowChange and another Delay code for blackChange. i put the delay code inside the action of making a song start. so when the song starts, it did the first delay and then the 2nd delay code worked too.THANKS

  • @ipodtouchacker bit.ly / jlU3Dr

  • @ipodtouchacker A void is a function much like an IBAction. You need to make a void like

    - (void)functionName {

    //code

    }

    As for the NSTimer, put myView.back­groundColor = [UIColor yellowColor] inside of a void and put the timer when you want to start the delay (viewDidLoad?). After the timer runs out it will call the function inside of the @selector(). So if you named the void functionName, you would put functionName inside of the @selector parenthesis.

  • @snipermaniac365 ok i completely failed at what you told me to do. do i make an ibaction to have the NSTimers do what they do? im confused. the void is mostly the confusing part for me. i don't know where to put it in the code. i would write -(void) [NSTimer scheduledTimerWithTimeInterval :(4) target:self selector:@selector(myView.back­groundColor = [UIColor yellowColor] userInfo:nil repeats:NO];

    but how would it know when to do that?

  • @ipodtouchacker Don't use sleep(). Make 2 NSTimers that are called when the button is pressed and set the delay to however many seconds you want it to take for the void that contains the background changing code to be called. [NSTimer scheduledTimerWithTimeInterval­:(seconds) target:self selector:@selector(anyFunction­) userInfo:nil repeats:NO];

  • @snipermaniac365 okay so the ibaction makes something happen to an object/outlet. and a void is just automatic actions? the thing im trying to do is have the screen change to yellow after 4 seconds when a song starts and black after another 4 or 5 seconds. i have the button make the song start and i made the background color change to yellow by doing a sleep(4), but i can't do it again for black color

  • @ipodtouchacker IBAction is a subclass of void and void returns nothing. IBAction is the exact same thing as viod but interface builder looks at them and parses them differently.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more