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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:44:38+00:00 2026-06-04T19:44:38+00:00

I have a custom UITableViewCell which contains 3 UILabels. Two of these labels are

  • 0

I have a custom UITableViewCell which contains 3 UILabels. Two of these labels are aligned with the left hand side of the cell, the other one is aligned on the right hand side. Here is what it looks like:

enter image description here

The issue I’m having is when the UITableView is in editing mode. I have been trying to stop the labels on the right from disappearing off the side of the screen through the use of AutoResizingMasks but I’m not having any luck. Here is what happens:

enter image description here

The code I have been playing around with comes from my subclasses UITableViewCell. Here is my code:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

    if (self) 
    {
        // Setup the cells accessory
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        // Setup the cell background
        self.backgroundView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"Plain_Cell.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0]];

        // Setup the Main label (fruit names)
        mainLabel = [[UILabel alloc] init];
        mainLabel.font = [UIFont systemFontOfSize:25];
        mainLabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:mainLabel];

        // Setup the dates label
        datesLabel = [[UILabel alloc] init];
        datesLabel.font = [UIFont systemFontOfSize:14];
        datesLabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:datesLabel];

        // Setup the milage label
        distanceLabel = [[UILabel alloc] init];
        distanceLabel.textAlignment = UITextAlignmentRight;
        distanceLabel.font = [UIFont systemFontOfSize:14];
        distanceLabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:distanceLabel];
    }

    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];

    mainLabel.frame = CGRectMake(10, 10, 280, 39);
    datesLabel.frame = CGRectMake(10, 58, 184, 21);
    distanceLabel.frame = CGRectMake(205, 58, 85, 21);

    mainLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin;
    datesLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin;
    distanceLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin;
}

NOTE: Please scroll down for more code!

I haven’t had much luck with it though. Please can someone help me out?

  • 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-04T19:44:40+00:00Added an answer on June 4, 2026 at 7:44 pm

    You are aligning your text to the right, but not the label. Try this:

    ...
    // Setup the mileage label
    distanceLabel = [[UILabel alloc] init];
    distanceLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
    distanceLabel.textAlignment = UITextAlignmentRight;
    distanceLabel.font = [UIFont systemFontOfSize:14];
    distanceLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:distanceLabel];
    

    This will lock the right margin where it is and allow the left margin to shrink when the view shrinks.

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

Sidebar

Related Questions

I have a custom UITableViewCell which contains several UIButtons. Each button's frame position is
I have custom UITableViewCell . It contains UITextLabel . When I press this cell
I have a custom UITableViewCell which is part of a navigation controller. The cell
I have a custom UITableViewCell that contains a UISlider control and a UILabel which
I have a custom UITableViewCell which has some subviews. i.e. some labels, some images.
I have a custom-subclassed UITableViewCell which will include a few labels, to which I
I have a custom UITableViewCell which fills the cell with a background PNG and
I have created a custom UITableViewCell which is composed by 2 UILabels and a
I have a subclass of UITableViewCell which contains several elements - UIImageViews, Labels, etc.
I created a custom UITableViewCell which is the same as the Left Detail cell

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.