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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:50:53+00:00 2026-06-14T12:50:53+00:00

I have an NSTableView, which should resize it’s frame when a row is added.

  • 0

I have an NSTableView, which should resize it’s frame when a row is added.
I would make 2 properties, maxHeight and minHeight, and if any rows are being added or removed, I would resize the table view to fit it’s content, if it doesn’t cross the limit.

Like the Safari Download Panel (10.7 or later).
Has anyone an idea how to do this?
I would want to handle this in a subclass. So no messing with the resizing in the delegate class.

I would at least need to know which method is being called when the table view is being reloaded. reloadTable only invokes the real reloading method, so no success there.

  • 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-14T12:50:55+00:00Added an answer on June 14, 2026 at 12:50 pm

    I did something similar a while back and I did it on the controller, not on a subclass (sorry if it’s not what you’re looking for). Basically I wrote a method that computed the height of the tableview by adding the height of all the rows. And every time I added or removed a row from the table I’d call that method. Here is something to get you started:

    - (void)adjustTableSize
    {
        NSInteger minHeight = ...
        NSInteger maxHeight = ...
    
        NSInteger tViewHeight = 0;
        for (int i = 0; i < [tableView numberOfRows]; i++) {
            NSView* v = [tableView viewAtColumn: 0 row: i makeIfNecessary: YES]; // Note that this is for view-based tableviews
            tViewHeight += v.frame.size.height;
        }
    
        NSInteger result = MIN(MAX(tViewHeight, minHeight), maxHeight);
    
        // Do something with result here
    }
    

    If you really want it on a subclass it should possible, but it might be a pain to work out how…

    EDIT:

    If you don’t mind working with undocummented APIs, here’s a simpler version:

    - (void)adjustTableSize
    {
        NSInteger minHeight = ...
        NSInteger maxHeight = ...
        NSInteger result = MIN(MAX([tableView _minimumFrameSize].height, minHeight), maxHeight);
    
        // Do something with result here
    }
    

    Since this is undocummented I can’t promise it’ll work, but from my testing so far it does. And it might be faster than creating views just to get their height, specially if you have lots of rows.

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

Sidebar

Related Questions

I have an NSTableView which is bound to an NSArrayController. I would like to
In my application, I have an NSTableView which should contain a list of files.
I have a code which returns selected row for NStableView as under: int status;
I have an NSTableView which displays some information representing a custom object of mine.
I have an NSTableView which is bound to an NSDictionaryController. I have set this
I have an NSTableview which s bound to a NSArrayController. The Table/Arraycontroller contains Core
I have a NSTableView which has cells which can be edited, but when I
Current Situation: Direct Binding I have an NSTableView which displays the data that comes
I have a NSTableView which contains my custom NSCell subclass, IconCell. The IconCell contains
hi i have a NSTableView in a view controller class i have added an

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.