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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:17:03+00:00 2026-05-23T00:17:03+00:00

Edit: I’m starting a bounty on this one, as I’m looking for a cleaner

  • 0

Edit: I’m starting a bounty on this one, as I’m looking for a “cleaner” solution with a UITableViewCell subclass, rather than messing with the UITableView delegate and datasource. Ideally, I’d like to see how could I also handle the UISlider events. Thanks!

I am using a group-styled UITableView and I have several cells that look like this:

enter image description here

Now, while I’m in editing mode, I’d like to have a UISlider that sets the value of the right UILabel, so that the result would look like this:

enter image description here

Could someone point me to the right direction? I’m not even sure if I should do that by subclassing UITableViewCell or in IB. Code snippets would be highly appreciated 🙂

  • 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-23T00:17:04+00:00Added an answer on May 23, 2026 at 12:17 am

    First of all, create a new Navigation-based Project, then create a new class file named CustomCell.h and CustomCell.m, respectively.

    Copy and paste this code into your RootViewController.m file:

    #import "RootViewController.h"
    #import "CustomCell.h"
    
    @implementation RootViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        self.navigationItem.rightBarButtonItem=self.editButtonItem;
    }
    
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 2;
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return 1;
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
    
        CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[CustomCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
        }
        cell.mainLabel.text=@"ValueName";
    
        return cell;
    }
    
    - (void)setEditing:(BOOL)editing animated:(BOOL)animated
    {
        [super setEditing:editing animated:animated];
        [self.tableView beginUpdates];
        [self.tableView endUpdates];
    }
    
    - (float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if(tableView.editing){
            return 70;
        }
        return 44;
    }
    
    - (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return NO;
    }
    
    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return UITableViewCellEditingStyleNone;
    }
    
    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return;
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
    }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
    }
    
    - (void)dealloc
    {
        [super dealloc];
    }
    
    @end
    

    CustomCell.h:

    #import <UIKit/UIKit.h>
    
    
    @interface CustomCell : UITableViewCell {
    
    }
    
    @property (nonatomic, retain) UILabel *mainLabel;
    @property (nonatomic, retain) UILabel *detailLabel;
    @property (nonatomic, retain) UISlider *slider;
    
    @end
    

    CustomCell.m:

    #import "CustomCell.h"
    
    @implementation CustomCell
    @synthesize mainLabel, detailLabel, slider;
    
    - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
        if (self) {
            slider = [[UISlider alloc] initWithFrame:CGRectMake(10, 12, 280, 0)];
            slider.alpha = 0;
            slider.maximumValue = 30;
            slider.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
            [self.contentView addSubview:slider];
            [slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventTouchDragInside];
            [slider release];
    
            mainLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 12, 150, 20)];
            mainLabel.highlightedTextColor = [UIColor whiteColor];
            mainLabel.backgroundColor = [UIColor clearColor];
            [self.contentView addSubview:mainLabel];
            [mainLabel release];
    
            detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width-180, 12, 150, 20)];
            detailLabel.textAlignment=UITextAlignmentRight;
            detailLabel.text = [NSString stringWithFormat:@"%i", lroundf(slider.value)];
            detailLabel.highlightedTextColor = [UIColor whiteColor];
            detailLabel.backgroundColor = [UIColor clearColor];
            [self.contentView addSubview:detailLabel];
            [detailLabel release];
        }
        return self;
    }
    
    - (void)setEditing:(BOOL)editing animated:(BOOL)animated
    {
        [super setEditing:editing animated:animated];
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.3];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationBeginsFromCurrentState:YES];
    
        if(editing){
            slider.alpha = 1;
            slider.userInteractionEnabled=YES;
        }else{
            slider.alpha = 0;
            slider.userInteractionEnabled=NO;
        }
    
        [UIView commitAnimations];
    }
    
    -(IBAction) sliderChanged:(id) sender{
        detailLabel.text=[NSString stringWithFormat:@"%i", lroundf(slider.value)];
    }
    
    - (void)dealloc
    {
        [super dealloc];
    }
    
    @end
    

    Compile and run and you have a perfectly fine version of the controls you wanted. I even implemented animations as smooth as butter. Have fun!

    EDIT:
    If you do want to use the editing-controls, you must not implement the following method and have to adjust the frame of the labels and the slider.

    - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return UITableViewCellEditingStyleNone;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT : The current code is the working solution, the one which does not
EDIT: I finally found a real simple solution to this problem, using the CAGradientLayer
EDIT: looking for this: http://diminishing.org/extending-formtastic-with-a-sprinkle-of-jquery (If this works I'll answer my own question) I've
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT : It turned out that this can only be done through an external
Edit: The reason I am looking if caching large data(entire database, or lots of
Edit 08/01/2014 As of this edit time I realised that the subject property db.UserProperty()
EDIT:This did it: SELECT DISTINCT profileid FROM profilesrelevation WHERE profileid NOT IN ( SELECT
EDIT: for those who come here with a similar problem, now i know this
--EDIT-- I believe this is a valid question that may have multiple answers (as

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.