Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6205613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:18:20+00:00 2026-05-24T05:18:20+00:00

How do I update a UISlider’s value property after its minimum and maximumValues have

  • 0

How do I update a UISlider’s value property after its minimum and maximumValues have been changed (during runtime)?

Consider the following Code:

1 UILabel hooked up to an IBOutlet – label

1 UISlider (default Settings min=0, max=1) hooked up to an IBOutlet – slider and an IBAction – valueChanged

1 Button hooked up to an IBAction – buttonTouch

and the following two IBAction implementations:

- (IBAction)valueChanged:(id)sender {
    label.text=[NSString stringWithFormat:@"%f",slider.value];
}

- (IBAction)buttonTouch:(id)sender {
    slider.maximumValue=4;
    slider.minimumValue=2;
    label.text=[NSString stringWithFormat:@"%f",slider.value];
}

When I move the slider to a certain position it get’s updated correctly.

However, when I change the Sliders’s minimum and maximumValues by triggering the buttonTouch IBAction the slider.value property doesn’t change – it still shows the old value (between 0 and 1). So changing the minimum and maximum properties doesn’t have a direct effect on the value property.


Before:

min=0 value=0.5 max=1

After:

min=2 value=0.5 max=4

This is supposed to be 3!


I guess you could calculate the new value based on your knowledge of the value, min and max for the old setting and min and max for the new setting, but that doesn’t seem to be a nice solution (see formula below)

newValue = oldvalue / (oldmax - oldmin) * (newmax - newmin) + newmin

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:18:22+00:00Added an answer on May 24, 2026 at 5:18 am

    You should update the value manually. UIKit can not and do not make any guess as to what to do with the value when the min and max limits changes.

    Should it be truncated at the edges? Should it be a close approximation within the new range? There are many more possible solutions but the one you desire for this particular case. UIKit makes the sane choice of making no choice, and instead leave it up to you to tell what to do.

    There is also a golden rule (with a few exceptions) that changing one property should not affect another property. Only action methods are allowed to change more than one state. Perhaps you should add your own method as a category: -(void)[UISlider setMinimumValue:(CGFloat)maximumValue:(CGFloat)adjustingValueForNewRange:(BOOL)].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UISlider that I want to update a UITextField for the value
I have a UISlider that is supposed to update the color of a textlabel.
Update: Thanks for the suggestions guys. After further research, I’ve reformulated the question here:
UPDATE 4.0 Seems like iOS 4.0 changed something here. Same code producing incorrect backgrounds
I have tried many methods to implement a regular UISlider and control the device
UPDATE: I now have a solution I'm much happier with that, whilst not solving
I have a custom UITableViewCell that contains a UISlider control and a UILabel which
I have an audio scrubber consisting of a UISlider and two UILabel s on
UPDATE 1 ADDED UPDATED CODE I have a django template on app engine. Currently
UPDATE: This question and its answers should no longer be recommended to anyone reading

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.