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 6215683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:06:03+00:00 2026-05-24T07:06:03+00:00

Basicly, I’m making an app that lets you add or subtract by a certain

  • 0

Basicly, I’m making an app that lets you add or subtract by a certain number and I want to do so with a slider. How would I program a slider to be able to add or subtract by an integer by tapping a different button for adding and subtracting. For example, say you want to add by 3. You slide the bar to three then tap the “+” to add three. How would I program this?

EDIT: This is the code that I want to implement it in:

int number = 0

-(IBAction)IncrementNumber:(id)sender {
    number++;
    [currentNumber setText:[NSString stringWithFormat:@"%d", number]];
}

-(IBAction)DecrementNumber:(id)sender {
    number--;
    [currentNumber setText:[NSString stringWithFormat:@"%d", number]];
}

@synthesize MySlider, MyTextField;  

-(IBAction) sliderValueChanged:(UISlider *)sender {  
    MyTextField.text = [NSString stringWithFormat:@" %1.0f", [sender value]];  
}  

-(IBAction) changeButtonPressed:(id)sender {  
    NSString *textValue = [MyTextField text];  
    float value = [textValue floatValue];  
    if (value < 0) value = 1;  
    if (value > 100) value = 100;  
    MySlider.value = value;  
    MyTextField.text = [NSString stringWithFormat:@"%1.0f", value];  
    if ([MyTextField canResignFirstResponder]) [MyTextField resignFirstResponder];  
}  

-(void) touchesBegan: (NSSet *) touches withEvent: (UIEvent *) event {  
    if (MyTextField) {  
    if ([MyTextField canResignFirstResponder]) [MyTextField resignFirstResponder];  
}
  • 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-24T07:06:04+00:00Added an answer on May 24, 2026 at 7:06 am

    You could bind the slider to some variable, and the two buttons, [+] and [-] to two functions, say add and sub.
    When the functions are called, they grab the value from the variable, and add / subtract it to / from something.

    In your edit, assuming that sliderValueChanged is called when the slider value is changed, that function should alter number, so that IncrementNumber and DecrementNumber can have the updated value.

    What should work is to define number as IBOutlet in your header file (.h). Then, in interface builder, you can bind the value of the slider to number. This way, whenever you change de slider, the number variable changes accordingly.
    In the interface, declare two functions that will be bound to the [+] and [-] boutons:

    IBOutlet int number;
    -(IBAction) add: (id) sender;
    -(IBAction) sub: (id) sender;
    

    In the definition of those functions, you take whatever number you want to change and add to it the number variable that you declared earlier.

    Something like the following should do the trick, if value has the number you want to modify:

    -(IBAction) add: (id) sender {
        value += number;
    }
    -(IBAction) sub: (id) sender {
        value -= number;
    }
    

    You could of course combine the two functions into one, and decide wether you should add or subtract according to which button was pressed (you get that by looking into the sender argument) but I think it’s less effective, and the code woud be more complex for no reason.

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

Sidebar

Related Questions

Basicly I'm making an image gallery that downloads from the web. So - when
I need to develop an app that is using multithreading. Basicly, I have a
I want to make a program that concatenates an exe and data into one
Basicly what I need is to be able to rename an XmlElement (which is
Basicly, what I need for the program to do is to act a as
basicly I've got an array and want to call the same function for each
So basicly what I'm trying to accomplish is that foreach row in mysql query
I basicly need to load the whole XML file, add a new line with
hoping some one can shed some light on my problem. Basicly I only want
Ok, basicly, I made a script (that one) that makes a .post to a

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.