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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:44:16+00:00 2026-05-21T11:44:16+00:00

I have a UITableViewCell which detailTextLabel causes the cells frame to be dependant on

  • 0

I have a UITableViewCell which detailTextLabel causes the cells frame to be dependant on its size.

My code for that is this:

cell for row at index method

cell.textLabel.text = @"Rights";
            cell.backgroundColor = [UIColor clearColor];
            cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
            cell.detailTextLabel.numberOfLines = 0;
            cell.detailTextLabel.text = [self getItemForKey:kRights];
            cell.textLabel.font = [UIFont systemFontOfSize:15];
            cell.detailTextLabel.font = cell.textLabel.font;
            cell.textLabel.textColor = [UIColor colorWithRed:54.0f/255.0f green:54.0f/255.0f blue:54.0f/255.0f alpha:1.0f];
            CGSize constraintSize = CGSizeMake(310.0f, MAXFLOAT);
            CGSize labelSize = [[cell.detailTextLabel text] sizeWithFont:[cell.detailTextLabel font] constrainedToSize:constraintSize lineBreakMode:UILineBreakModeWordWrap];
            cell.detailTextLabel.frame = CGRectMake( 0, 0, 310, labelSize.height);
            cell.userInteractionEnabled = YES;
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.accessoryType = UITableViewCellAccessoryNone;

Height for row at index method

 if (indexPath.row == 3){
                NSString *text = [self getItemForKey:kRights];
                CGSize constraintSize = CGSizeMake(310.0f, MAXFLOAT);
                CGSize labelSize = [text sizeWithFont:[UIFont systemFontOfSize:15]
                                    constrainedToSize:constraintSize 
                                        lineBreakMode:UILineBreakModeWordWrap];
                return labelSize.height+11;
            }

However, if the size of the label is too big, the cells overlap each other. Please could you tell me how I can prevent this?

Here is an image to show you my problem:

http://img689.imageshack.us/i/screenshot2011042102520.png/

  • 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-21T11:44:17+00:00Added an answer on May 21, 2026 at 11:44 am

    Did you just forget, in the height for row at index method, to account for the rest of the content of the cell? You are adding 11 points to the height of the detailTextLabel. It doesn’t look like that’s enough. Running [@”Rights” sizeWithFont:[UIFont systemFontOfSize:15]] returns a height of 19. So, you would need that much to account for the textLabel height, plus any space you leave between textLabel & detail, plus top and bottom margins within the cell, plus any other content of the cell.

    Also, from your screen shot, it seems like you might have some overlapping of the content within this particular cell. That could be a result of the frame you’re setting for the detailTextLabel:

    cell.detailTextLabel.frame = CGRectMake( 0, 0, 310, labelSize.height);
    

    You set the origin of the frame at (0, 0), that is, the top left corner of the cell. That would make the detailTextLabel overlap the textLabel for the cell.

    Hope this is helpful.

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

Sidebar

Related Questions

I have created a class named ListCell which is a subclass of UITableViewCell .
I have successfully created a UITableView/UITableViewCell that is able to slide up and down
I am trying to create 3 table view cells using code (w/o nib). I
Have the following scenario. I have a few form, which essentially have a few
I have a Spring project that uses Maven and has several profiles to allow
I created a custom UITableViewCell in my app and the default indent when the
This is yet another EXC_BAD_ACCESS question. Although I've done my homework and am certain
have anyone found a substitution for RJS in Ruby on Rails for play? P.S.
have different files with same name, in different directories. In these files there are
As the title says none of my tableview controller methods are being called. The

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.