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

The Archive Base Latest Questions

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

I have a UITableView with a variable number of rows (cells) – the height

  • 0

I have a UITableView with a variable number of rows (cells) – the height of these rows is constant. What I would like is to make the height of the UITableView depend on the number of rows.

Also, I would like the UITableView to be exactly wrapping the cells, so no padding at the bottom. So if a cell has height 60, tableview should be 60 for one cell, 120 for two cells, etc…

Thanks in advance!

  • 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-13T07:14:28+00:00Added an answer on June 13, 2026 at 7:14 am

    You could access your data source to find the number of cells that will be displayed. Multiply this number by the height of one row and you get the height of the entire table view. To change the height of a table view, you can change its frame property.

    You can access the (constant) height of one row of your table view by accessing its rowHeight property. If you fill your table view with the objects of an array called myArray, you could use the following code:

    CGFloat height = self.tableView.rowHeight;
    height *= myArray.count;
    
    CGRect tableFrame = self.tableView.frame;
    tableFrame.size.height = height;
    self.tableView.frame = tableFrame;
    

    You could also find out how many rows the table view will contain by asking the table view itself, instead of the data object. Something like this should work:

    NSInteger numberOfCells = 0;
    
    //finding the number of cells in your table view by looping through its sections
    for (NSInteger section = 0; section < [self numberOfSectionsInTableView:self.tableView]; section++)
        numberOfCells += [self tableView:self.tableView numberOfRowsInSection:section];
    
    CGFloat height = numberOfCells * self.tableView.rowHeight;
    
    CGRect tableFrame = self.tableView.frame;
    tableFrame.size.height = height;
    self.tableView.frame = tableFrame;
    
    //then the tableView must be redrawn
    [self.tableView setNeedsDisplay];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView with cells containing variable-height UILabels. I am able to calculate
I have a UITableView that is populated with cells of a variable height. I
I have UITableView with images as rows (cells). I use EGOImageView to load images
I have a UITableView and would like to apply a background image to all
I have a table view where the cells have a variable height. This causes
I have a UITableView in another view. I want to make the height of
I have a UITableView with a variable amount of cells, each with a UISwitch
I have a UITableView in my UIView, that has variable number of sections, depending
I have UITableView with very large cells with lots of content (more than one
I have a UITableView which is configured to allow rows to be moved between

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.