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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:14:42+00:00 2026-05-25T03:14:42+00:00

I have created a UITableViewCell with a NIB file. There is 1 label in

  • 0

I have created a UITableViewCell with a NIB file.
There is 1 label in it which is going to contain a tweet. So it needs to be a dynamic height. There also is a timeAgo label that has to fit underneath the tweet label.

I’m trying stuff with frames en sizes but I can’t get the perfect solution..
I do this in the UITableViewCell file in the drawrect method.

self.tweet.lineBreakMode = UILineBreakModeWordWrap;
self.tweet.numberOfLines = 0;
self.tweet.font = [UIFont fontWithName:@"Arial" size:13.0f];
[self.tweet sizeToFit];  

CGFloat tweetHeight = self.tweet.frame.size.height;

self.timeAgo.lineBreakMode = UILineBreakModeWordWrap;
self.timeAgo.numberOfLines = 0;
self.timeAgo.font = [UIFont fontWithName:@"Arial" size:11.0f];
[self.timeAgo sizeToFit];

CGFloat timeAgoHeight = self.timeAgo.frame.size.height;

self.timeAgo.frame = CGRectMake(88, tweetHeight, 100, timeAgoHeight + 10.0f);

I have also tried a stringhelper which I found in a tutorial.

The:

- (CGFloat)RAD_textHeightForSystemFontOfSize:(CGFloat)size {

My HeightForRow methods is also already different because I use different cell styles.
At the moment I return a hard value for each cell style but that also needs to change to the cellheight.

  • 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-25T03:14:43+00:00Added an answer on May 25, 2026 at 3:14 am

    See this tutorial, http://www.cimgf.com/2009/09/23/uitableviewcell-dynamic-height/

    The trick is to make the label grow with the size of the cell, than you can just set the size of the cell and the cell will grow with it.

    Set the timeAgo label to align it self to the bottom of the cell.

    Set the numberOfLines of tweet to 0 via IB,re move all the draw code and only implement the following:

    - (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
        id item  = [self.item objectAtIndex:indexpath.row];
    
        CGFloat height = 85.0f;
    
        if ([item isKindOfClass:[Tweet class]]) {
            Tweet *tweet = (Tweet *)item;
            CGSize titleSize = [tweet.tweet sizeWithFont:[UIFont fontWithName:@"Arial" size:13.0f] constrainedToSize:CGSizeMake(260.0f, MAXFLOAT)];
    
            // adde the 24 pixels to get the height plus the time ago label.
            height =  titleSize.height + 24.0f;
    
        } else if( [item isKinfOfClass:[SC_Release class]]) {
            height = 65.0f;
        }
    
       return height;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have UItableViewCell created with a nib file, and have put in my cell
Hi have setup a UITableViewCell from a nib file and everything is working as
I have a custom UITableViewCell which I created in Interface Builder. I am successfully
I have created a UITableViewCell using UITableViewCellStyleValue1, which the Apple docs define as: A
I created a UITableViewCell in Interface Builder which I have added a UIImageView and
I have created a class named ListCell which is a subclass of UITableViewCell .
I have a nib-based table view cell which I created in Interface builder. I
I have created a C# class file by using a XSD-file as an input.
I've created some custom UITableViewCells in a nib file and would like to use
I have a UITableView inside of a View created from a NIB. the table

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.