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

  • Home
  • SEARCH
  • 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 4038592
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:29:31+00:00 2026-05-20T12:29:31+00:00

How does one obtain the UITableViewCell when within the heightForRowAtIndexPath method, i.e. given the

  • 0

How does one obtain the UITableViewCell when within the heightForRowAtIndexPath method, i.e. given the indexPath?

(then I could access the content views I have created to add their heights up)

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
  // How to get the UITableViewCell associated with this indexPath?
}

thanks

EDIT: In fact is there really a valid way to do this? When I put some NSLog statements it seems that heightForRowAtIndexPath it called several times before the calls to cellForRowAtIndexPath (which is where I set up the UILabels in the cell)? This kind implies that I may be tried to use a technique that will not work, i.e. I was hoping in heightForRowAtIndexPath to access the already created labels in each cell to get their heights and add them together for the overall cell row height, HOWEVER if they haven’t been set up yet (within cellForRowAtIndexPath) then I guess my approach can’t really work?

  • 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-20T12:29:32+00:00Added an answer on May 20, 2026 at 12:29 pm

    For iOS8:

    override func viewDidLoad() {
            super.viewDidLoad()
    
            self.tableView.estimatedRowHeight = 80
            self.tableView.rowHeight = UITableViewAutomaticDimension
        }
    

    OR

    func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
                return UITableViewAutomaticDimension
    
        }
    

    But for iOS7, the key is calculate the height after autolayout,

    func calculateHeightForConfiguredSizingCell(cell: GSTableViewCell) -> CGFloat {
            cell.setNeedsLayout()
            cell.layoutIfNeeded()
            let height = cell.contentView.systemLayoutSizeFittingSize(UILayoutFittingExpandedSize).height + 1.0
            return height
    
        }
    

    Note:

    1) If multiple lines labels, don’t forget set the numberOfLines to 0.

    2) Don’t forget label.preferredMaxLayoutWidth = CGRectGetWidth(tableView.bounds)

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

Sidebar

Related Questions

In Spring, a method that is annotated with @Transactional will obtain a new transaction
I am using Facebook's PHP SDK and Graph API to obtain all albums from
Here is the situation. I have some ViewModels that contain nested complex model types.
I have been struggling with this for the entire day now, I hope somebody
We are not able to create the installer after migrating the code from VS2005
Yes, I know, WebKit uses a separate 32-bit process to play Flash and communicate
I really do not understand what is happening here but: when I do: colorIndex
To get Scrapy working on HTTPS, I need PyOpenSSL , but I can't seem
I'm trying to inject Spring beans into an EJB using @Interceptors(SpringBeanAutowiringInterceptor.class) but I cannot

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.