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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:49:11+00:00 2026-05-30T07:49:11+00:00

I have a UITableView populated with custom UITableViewCells. Within those custom cells, I have

  • 0

I have a UITableView populated with custom UITableViewCells. Within those custom cells, I have a UITextField and a “See More” UIButton. The purpose of the UIButton is to dynamically expand that particular UITableCell when the user wishes to read more of the text. In the same way, when the user wishes to return to the original size, the user clicks the Button again, and the UITableViewCell will shrink to the original size.

Since the cell isn’t being selected, I setup an IBAction within the Custom Cell like such:

//Within CustomCell.m

- (IBAction)showMoreText:(id)sender
{
    //instance bool variable to flag whether the cell has been resized
    self.hasBeenResized = YES;

    //turn off mask to bounds, otherwise cell doesnt seem to resize
    [[self.cellView layer] setMasksToBounds:NO];

    // Calculate the new sizes and positions for the textView and the button 
    CGRect newTextViewFrame = self.textView.frame;
    newTextViewFrame.size.height = self.textView.contentSize.height;
    self.textView.frame = newTextViewFrame;

    CGFloat bottomYPos = self.textView.frame.origin.y + self.textView.frame.size.height;
    CGRect buttonFrame = self.showMoreButton.frame;
    buttonFrame.origin.y = bottomYPos;
    self.showMoreButton.frame = buttonFrame;

    // Call begin and end updates
    [(UITableView*) self.superview beginUpdates];   
    [(UITableView*) self.superview endUpdates];

    // Set mask and put rounded corners on the cell
    [[self.cellView layer] setMasksToBounds:YES];
    [[self.cellView layer] setCornerRadius:10.0];
}

Following this, I have this in my ViewController class:

// Within ViewController.m
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"heightForRowAtIndexPath");

    CustomCell *cell = (CustomCell*)[self tableView:tableView cellForRowAtIndexPath:indexPath];

    if([cell hasBeenResized] == NO)
    {
        return cell.frame.size.height + 20;
    }
    else
    {
        return cell.frame.size.height + cell.textView.frame.origin.y + cell.textView.frame.size.height + cell.showMoreButton.frame.size.height + 20;
    }
}

What happens now is I can see the custom cell change the size of its textview, however, the table does not update the row height for that particular cell. Checking on the If-else statement there, it appears that hasBeenResized is always false, even though I set it to YES within the IBACtion of the CustomCell.

I have looked at other solutions here, but they all seem to involve didSelectRowAtIndexPath, which I cannot use in this instance (I have another behavior for the cell when it is selected).

Am I doing this completely wrong? Ideally, what I would like to do is to have the “Show More” button animate downwards as the textview is expanded and vice versa when it’s collapsed.

Thank you!

  • 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-30T07:49:13+00:00Added an answer on May 30, 2026 at 7:49 am

    Method beginUpdates won’t call reloadData for you – you have to do it manually.

    For your case it would be best to call:

    - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
    

    And place your showMoreText code in tableView:cellForRowAtIndexPath: method (for selected cell only)

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

Sidebar

Related Questions

I have UITableView with very large cells with lots of content (more than one
I have a UITableView that is populated with cells of a variable height. I
I have a custom view MyView : UIViewController <UITableViewDelegate, UITableViewDataSource> with a UITableView within
I have a UITableView populated with a location-based datasource. I'm calling [self updateView]; to
I have a UITableView which is populated by an array, I have a button
I have an application that has a UITableView. This UITableView is populated by an
I have a working UITableView in my view controller. It is being successfully populated
I have a UITableView populated (previously saved via a button in navbar), with transactions.
I have an UITableView populated by a NSFetchedResultsController . The initial fetch works fine.
I have a UITableView that gets populated from CoreData via a controller that implements

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.