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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:34:46+00:00 2026-06-14T23:34:46+00:00

I have an NSTableView that has a single column, with rows that contain a

  • 0

I have an NSTableView that has a single column, with rows that contain a WebKit WebView. The problem I am having is how can I get the size of the WebView so I can set the height in the table view’s heightOfRow: method.

Here is the relevant parts of code:

// The only essential/required tableview dataSource method
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView {
    return [self.messagesArray count];
}

// This method is optional if you use bindings to provide the data
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {

    NSString *identifier = [tableColumn identifier];
    if ([identifier isEqualToString:@"MainCell"]) {

        ChatTableViewCell *cellView = (ChatTableViewCell*)[tableView makeViewWithIdentifier:@"MainCell" owner:self];
        NSString *htmlString = [self.messagesArray objectAtIndex:row];
        [[cellView.webView mainFrame] loadHTMLString:htmlString baseURL:nil];
        [cellView.webView.mainFrame.frameView setAllowsScrolling:NO];

        return cellView;
    }

    return nil;
}

The problem I have is how to get the size in this method. Everything I have tried so far is giving me an exception. I think it’s because the cell is not initialized properly when the following method is called, and that the WebView method loadHTMLString is asynchronous.

-(CGFloat) tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
    //What can I put here?
}

I want to be able to resize the cell to the same size as the content in the WebView.

EDIT: I tried adding the following to the heightOfRow method:

    WebView *webView = [((ChatTableViewCell*)[tableView viewAtColumn:0 row:row makeIfNecessary:YES]) webView];
    NSRect webViewRect = [webView frame];
    return webViewRect.size.height;

And it gives me the following:

WARNING: NSTableView detected a rowView was requested from inside of the -heightOfRow delegate method. That is not supported!

  • 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-14T23:34:47+00:00Added an answer on June 14, 2026 at 11:34 pm

    Try this it will give you the height of the webview content..

    Load the webview with html string like this..

    embedHTML = [embedHTML stringByAppendingFormat:@"<body><div id='size_div'>%@</div></body></html>",YourString];
    

    And now in webViewDidFinishLoad method keep this statements…

    NSString *output = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"size_div\").offsetHeight;"];  
    NSLog(@"height: %@", output);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view-based NSTableView that usually has one column in it. However, at
I have an NSTableView that has one column of editable fields. Cell editing works
I have an NSTableView that has 2 columns, one for an icon and the
I have an NSTableView that is displaying different views for each cell. How can
In my application, I have a NSWindow that has a NSTableView object and a
I have an NSCrollView that contains an NSTableView. It has 3 columns and 4
I have a NSTableView that holds a name to all of my NSImageView's, and
I have an NSTableView that contains a few columns that are populated with data.
I have an NSTableView that is done using the typical IB and data bindings.
I have a problem with sorting NSTableColumn contents. In my NSTableView there are three

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.