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

  • Home
  • SEARCH
  • 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 9171519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:10:26+00:00 2026-06-17T16:10:26+00:00

I’m developing my first iOS app which contains a UISlider . I know how

  • 0

I’m developing my first iOS app which contains a UISlider. I know how to get the value when the UISlider is dragged. But for my app I need to get the slider’s value in a single touch; i.e. if I touch somewhere in the UISlider, a UILabel should display its correct value.

Is it possible to this way. Any tutorial or code will very helpful.

  • 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-06-17T16:10:27+00:00Added an answer on June 17, 2026 at 4:10 pm

    Here tapCount is int variable that declare in .h file

    - (void)viewDidLoad
    {
      tapCount = 0; // Count tap on Slider 
    
     UITapGestureRecognizer *gr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(sliderTapped:)];
        [slider addGestureRecognizer:gr];
        
    }
    
     - (void)sliderTapped:(UIGestureRecognizer *)g 
        {
    /////////////// For TapCount////////////
    
            tapCount = tapCount + 1;
            NSLog(@"Tap Count -- %d",tapCount);
    
    /////////////// For TapCount////////////
    
            UISlider* s = (UISlider*)g.view;
            if (s.highlighted)
                return; // tap on thumb, let slider deal with it
            CGPoint pt = [g locationInView: s];
            CGFloat percentage = pt.x / s.bounds.size.width;
            CGFloat delta = percentage * (s.maximumValue - s.minimumValue);
            CGFloat value = s.minimumValue + delta;
            [s setValue:value animated:YES];
            
            NSString *str=[NSString stringWithFormat:@"%.f",[self.slider value]];
            self.lbl.text=str;
        }
    

    For Swift User

    override func viewDidLoad()
    {
        super.viewDidLoad()
    
        tapCount = 0
        let gr = UITapGestureRecognizer(target: self, action: #selector(self.sliderTapped(_:)))
        slider.addGestureRecognizer(gr)
    
    }
    
    func sliderTapped(_ g: UIGestureRecognizer) {
        
        /////////////// For TapCount////////////
        tapCount = tapCount + 1
        print("Tap Count -- \(tapCount)")
        /////////////// For TapCount////////////
        
        let s: UISlider? = (g.view as? UISlider)
        if (s?.isHighlighted)! {
            return
        }
        
        // tap on thumb, let slider deal with it
        let pt: CGPoint = g.location(in: s)
        let percentage = pt.x / (s?.bounds.size.width)!
        let delta = Float(percentage) * Float((s?.maximumValue)! - (s?.minimumValue)!)
        let value = (s?.minimumValue)! + delta
        s?.setValue(Float(value), animated: true)
        let str = String(format: "%.f", slider.value)
        lbl.text = str
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need to clean up various Word 'smart' characters in user input, including but
I am writing an app for my school newspaper, which is run completely online
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters

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.