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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:32:01+00:00 2026-05-25T09:32:01+00:00

Trying to understand when the cell height is set. I have a UITableView that

  • 0

Trying to understand when the cell height is set.
I have a UITableView that is created in layout, not code.

Then:

#define TABLE_VIEW_ROW_HEIGHT   100.0

Followed by:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Setting row height");
    return TABLE_VIEW_ROW_HEIGHT;
}

and

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Row height: %f", tableView.rowHeight);
    // ... other happy stuff that does not change row height but could sure use the real row height

The last NSLog reports 44 rather than 100. Which means that the code within that method that needs to get the row height is not using the real height.

I’ve verified that

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

runs before

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

And, as a result, the rows are of the desired size, not the default size of 44.

Do I need to explicitly set the height somewhere else?

EDIT AFTER DOING SOME RESEARCH:

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

…is more appropriately used to set the height of rows when not all rows are of the same height. I was wrongly using this to set all rows to the same height.

The right way to do it is to call

the_tableview.rowHeight = TABLE_VIEW_ROW_HEIGHT;

…from somewhere like viewDidLoad. I actually did that (code omitted) but it didn’t work. Tonight I realized that this is yet another instance of being had by the graphical layout tool…I forgot to connect the IBOutlet for the UITableView…so, my code did nothing and the entire tableview remained at the default height of 44. That’s why I was getting 44 out of my NSLog.

  • 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-25T09:32:02+00:00Added an answer on May 25, 2026 at 9:32 am

    In your code, you are calling the rowHeight on tableView and not on a specific row at IndexPath. That is the reason why you are getting the default value of 44. If you want to change the default value then you can do it in size inspector for the table. Changing the default value is better if all the rows have the same height. If there are rows with different heights then you will have to implement heightForRowAtIndexPath for that the rows with different heights.

    You have defined TABLE_VIEW_ROW_HEIGHT in code then in this case you will also have to set the tableView.rowHeight in code by assigning it the defined TABLE_VIEW_ROW_HEIGHT name.

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

Sidebar

Related Questions

After trying to understand why client code is not rendered in a page (injected
Just trying to understand that - I have never used it before. How is
Trying to understand Ruby a bit better, I ran into this code surfing the
Trying to understand something. I created a d:\svn\repository on my server. I committed folders
I've been trying to understand how Ruby blocks work, and to do that I've
I'm trying to understand someone else's Perl code without knowing much Perl myself. I
I have a cell with fixed height and I want the font size of
I am trying to create a UITableView that lists each teacher in my school
I'm trying to understand this code, and I still don't know why it starts
I'm new to GWT and trying to understand it, but have encountered with a

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.