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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:34:03+00:00 2026-05-15T13:34:03+00:00

I have a question that is driving me crazy. It is all about updating,

  • 0

I have a question that is driving me crazy. It is all about updating, in real time, an UITableViewCell with the value of an UISlider that is inside another UITableViewCell.

The problem

The cell is updated but It seems that the size of the Label in the cell does not addapt to the size of the value represented. I will try to explain better.

The UISlider has a minimumValue of -100 and a maximum value of 100. So, the first time the TableView is loaded, the cell.detailText.text shows 0.0% witch is displayed ok, but when I move the slider and the value is bigger, for example 55.5%, the label can not hold this extra characters and it displays “55…..”

This is how I create the cell that holds de UISlider Value create the UISlider in the cellForRowAtIndexPath delegate method


cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ProductCellIdentifier] autorelease];
cell.textLabel.text=@"Performance";
cell.detailTextLabel.text = [NSString stringWithFormat:@"%.1f%%", slider.value];
cell.tag=1002;

This is how I create de UISlider, in the cellForRowAtIndexPath method:


cell = [[[UITableViewCellalloc] initWithFrame:CGRectZero                                                           reuseIdentifier:ProductCellIdentifier] autorelease];

slider = [[UISlideralloc] initWithFrame:CGRectMake(90, 12, 200, 25)];

slider.maximumValue = 100;
slider.minimumValue = -100;
slider.continuous = TRUE;

[slideraddTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];

[cell.contentView addSubview:slider];
cell.tag=0;
[slider release];  

And this is what I do in the sliderChanged method in order to update the cell.


UITableViewCell *celda= (UITableViewCell *)[[self tableView] viewWithTag:1002];
celda.detailTextLabel.text = [NSString stringWithFormat:@"%.1f%%", slider.value];

I suspect that the solution is about the use of the reloadData method of the UITableView but not sure. I have tried inserting a self.tableView.reloadData in the sliderChanged method but I got then the UISlider does not move and finally I got this exception:
Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘ -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)’

Thanks in advance for your help
Javi

  • 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-15T13:34:03+00:00Added an answer on May 15, 2026 at 1:34 pm

    the problem is that detailTextLabel width is fixed and computed only when the label is going to be drawn in the cell.
    so, when you initialize the label with “0.0%” there is room for exactly 4 characters, and you cannot visualize correctly anything with more than that; extra charactes are either trimmed with “…” or the label just doesn’t display anything.

    i worked around this issue by forcing the label to contain additional spaces at the beginning of the string like this:

    while ([string length] <= 4)
          string = [NSString stringWithFormat:@" %@",prestring];
    cell.detailTextLabel.text = string;
    

    in this way, my slider can visualize correctly numbers from 0 to 999 correctly; since you have more characters just adjust the length desired.

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

Sidebar

Related Questions

I have 3 question about TransactionScopeOption.Required that driving me crazy and I cant find
I have a basic question that's driving me crazy. I have a class inheriting
I have this question that is driving me crazy: could I save a PDF
I have a question that is driving me crazy. I have a large number
I have a simple regex question that's driving me crazy. I have a variable
I have seen this question that talks about getting the last part of a
I have an AutoMapper issue that has been driving me crazy for way too
This is a newbie question that is driving me crazy. According to jQuery mobile
I have an error that has been driving me crazy for days. Unfortunately, I
I have a problem that has been driving me crazy and I'd appreciate any

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.