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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:27:30+00:00 2026-06-15T07:27:30+00:00

-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:indexPath]; return cell.bounds.size.height; } What

  • 0
-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:indexPath];
    return cell.bounds.size.height;
}

What would be the disadvantage?

I changed that from

-(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.bounds.size.height;
}
  • 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-15T07:27:31+00:00Added an answer on June 15, 2026 at 7:27 am

    As rmaddy points out, you can’t use the first version because -[UITableView cellForRowAtIndexPath:] can cause the table view to send you tableView:heightForRowAtIndexPath: again, resulting in infinite recursion.

    If you are using a static set of cells, with one cell preallocated for each row of the table, then the second version is fine.

    If you are dynamically creating cells for rows, the second version will end up draining your table view’s reuse queue and then creating another cell for every row, because tableView:cellForRowAtIndexPath: returns an autoreleased object. None of these cells will be deallocated until the end of the run loop, so in addition to the time cost of creating and destroying all of these cells, you’re also using memory proportional to the number of rows in your table. If you want to do it that way, and you have a lot of rows, you might want to use an explicit autorelease pool:

    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        @autoreleasepool {
            UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
            return cell.bounds.size.height;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am setting my height: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGFloat rowHeight =
I am using the code below to put together my UITableView. The Cell height
- (int)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection: (NSInteger)section {
I want to change the size of the selected cell. But, they shift position
When I scroll my tableview,the whole data in each cell reloads.It doesn't show any
I have made major changes and setup a custom class for the TableView Cell.
I have a UITableView and a UITableCell subclass. Each table cell has two scrollviews
I'm trying to implement a UIScrollView in each cell of `UITableView'. I wrote my
Is it possible to not float the section headers for a UITableView with style
I'm setting the tableView cells height dynamically according to labels height and labels height

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.