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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:41:31+00:00 2026-06-08T02:41:31+00:00

I have a UILabel that is currently displaying the value on a UISlider as

  • 0

I have a UILabel that is currently displaying the value on a UISlider as a value between 0 and 1 in increments of .1 (so it would display .1 or .2 or .3 etc up to 1). However I want to display this value as a % out of 100, but I’m not quite familiar with formatting floating point numbers. Here is the code I have right now:

sliderLabel.text = [NSString stringWithFormat:@"%.1f", [[f numberFromString:thresholdFile] floatValue]];  
  • 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-08T02:41:32+00:00Added an answer on June 8, 2026 at 2:41 am

    Haha, this can be tricky….
    From the printf docs:

    .number
    For e, E and f specifiers: this is the number of digits to be printed after the decimal point.

    Thus, what you really want is this:

    [NSString stringWithFormat:@"%f %%", [mySlider value] * 100];
    

    Let’s break this down, shall we?

    1. %f: Prints the first floating point number in the arguments list, which is:

      [mySlider value] * 100
      

      Notice the * 100 part there, which converts a number in the range of 0 ... 1 to a range of 0 ... 100. You may wish to call round() on this if you don’t want a decimal percentage.

    2. %%: Prints out an actual % character. This is because printf searches for switches that begin with the % character, and so if we had one verbatim in the string, it would throw a hissy fit. Thus, we escape that with another % (just like we would with a backslash), and it’s fine.

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

Sidebar

Related Questions

I have an application that has a UILabel displaying the current date and time,
I have a UILabel with right-aligned text that may vary from between three to
I have an NSString that then sets a UILabel. This contains unicode such as...
I have a custom UITableViewCell that contains a UISlider control and a UILabel which
I have a UIPicker with a UILabel above it that updates displaying the current
I have an UILabel that is centered in the screen. I want to place
So I have a UILabel that is linked to the current selected value of
I currently have some code that looks like: -(UIView)someMethod { CGRectMake(0,0,100,100); UILabel *label =
I have a UILabel that displays some chars. Like x, y or rpm. How
In my application I have a UILabel that holds an expanding number of entries

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.