iPhone Programming - UISlider Basics

Loading...

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

Uploaded by on Apr 9, 2011

A quick tutorial teaching you how to use a UISlider and get it's value to use for a purpose.

Main Code:
In the .h
IBOutlet UISlider *slider; IBOutlet UILabel *label; IBOutlet UILabel *counter;
}

- (IBAction)changeLabel;

In the .m
- (IBAction)changeLabel { counter.text = [[NSString alloc] initWithFormat:@"%.1f" ,slider.value]; if (slider.value (type SHIFT . here as YouTube won't let me post it as a character - the greater than sign)= 0.5) { label.text = @"Danger!"; label.textColor = [UIColor redColor]; } else { label.text = @""; label.textColor = [UIColor clearColor]; }
}

FlambeEmbers Channel: http://www.youtube.com/flambeember

Link: http://developer.apple.com/devcenter/ios/index.action
Website: http://failcake.webs.com/
Twitter: http://twitter.com/failcakeapps
Channel: http://youtube.com/milmersxcode

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (MilmersXcode)

  • Instead of this awkward if-else code, you could just write

    label.hidden = slider.value-0.5;

    And specify the red color and the text in the nib-file. And what's the point of the space before the comma in the stringWithFormat: call? You are emphasizing it, but beside that it's irrelevant it's even bad punctuation.

  • @mrjazzycharon2 The reason for the if-else code is to get people used to using them as this is a "Basics" tutorial. Of course it would be more basic to just do what you suggested but then people won't learn how to and become more fluent in using if-else statements.

    As for the "," when initializing the string it's because:

    1. I'm emphasizing it for the video's purpose.

    2. I believe it looks neater and more pleasing to the eye.

    I have my reasons for things :D.

    Milmer.

see all

All Comments (11)

Sign In or Sign Up now to post a comment!
  • Sorry, there shouldn't be a minus- but a smaller-character before 0.5.

  • @maxhasadhd Yea sorry it's just you put "Nameofslider.volume" in your last comment and I got a bit confused.

  • @maxhasadhd I don't really understand. How can a slider have a .volume? Anyway your video is now up and its called "Changing sites with UISegmentedControl" and it's in the UIWebView playlist. Hope you like :D

    I will get back to you tomorrow(10th April) on the UISlider stuff as it's late here.

  • @maxhasadhd Hey. Your Video is currently uploading and should be up by tonight but it keeps failing near the end of the upload :(. About the saving a UISlider I will get back to you.

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