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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:26:39+00:00 2026-06-15T01:26:39+00:00

I am experiencing a problem in Cocoa where the text in the textField of

  • 0

I am experiencing a problem in Cocoa where the text in the textField of an NSTableCellView is being cut off when I define the rowHeight of the tableView. It should be noted that all elements are being created programmatically. I am a bit new to Cocoa and am aware that a lot of what is below may well be below the quality of a dog’s breakfast and suggestions are welcomed.

My table is created thusly:

 ....
 NSScrollView * tableContainer = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, returnView.frame.size.width, 100)];
 NSTableView * tableView = [[NSTableView alloc] initWithFrame:NSMakeRect(0, 0, tableContainer.frame.size.width, 100)];
 [tableView setRowHeight:30];
 NSLog(@"tableView was created with a row height of %f", [tableView rowHeight]);
 ....

Within the viewForTableColumn method, I do the following:

- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {

// get an existing cell with the MyView identifier if it exists

NSTableCellView *result = [tableView makeViewWithIdentifier:@"MyView" owner:self];

// There is no existing cell to reuse so we will create a new one
if (result == nil) {

    result = [[NSTableCellView alloc] initWithFrame:NSMakeRect(0, 0, tableView.bounds.size.width, [tableView rowHeight])];

    // the identifier of the NSTextField instance is set to MyView. This
    // allows it to be re-used
    result.identifier = @"MyView";
}

// result is now guaranteed to be valid, either as a re-used cell
// or as a new cell, so set the stringValue of the cell to the
// nameArray value at row
NSLog(@"tableView row height is %f", [tableView rowHeight]);
NSLog(@"Cell bounds is {%f,%f} %f x %f", result.bounds.origin.x, result.bounds.origin.y, result.bounds.size.width, result.frame.size.height);
NSTextField *cellTF = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, result.bounds.size.height)];
NSLog(@"TextField size is {%f,%f} %f x %f", cellTF.frame.origin.x, cellTF.frame.origin.y, cellTF.frame.size.width, cellTF.frame.size.height);
[result addSubview:cellTF];
result.textField = cellTF;
[cellTF setBordered:NO];
[cellTF setEditable:NO];
[cellTF setDrawsBackground:NO];
result.textField.stringValue = @"hello";

NSLog(@"cell string value is now %@", [[result textField] stringValue]);

return result;

}

My log output is as follows (duplicate log entries for each row redacted):

WHCCConnect[26394:f07] tableView was created with a row height of 30.000000
WHCCConnect[26394:f07] tableView row height is 30.000000
WHCCConnect[26394:f07] Cell bounds is {0.000000,0.000000} 200.000000 x 30.000000
WHCCConnect[26394:f07] TextField size is {0.000000,0.000000} 100.000000 x 30.000000
WHCCConnect[26394:f07] cell string value is now hello row!

The actual result on the screen:

enter image description here

However, if I do not specify the rowHeight when creating the table, like this:

    NSScrollView * tableContainer = [[NSScrollView alloc] initWithFrame:NSMakeRect(0, 0, returnView.frame.size.width, 100)];
    NSTableView * tableView = [[NSTableView alloc] initWithFrame:NSMakeRect(0, 0, tableContainer.frame.size.width, 100)];
    //[tableView setRowHeight:30];

I get this as the output (duplicate log entries for each row redacted):

WHCCConnect[26458:f07] tableView was created with a row height of 17.000000
WHCCConnect[26458:f07] tableView row height is 17.000000
WHCCConnect[26458:f07] Cell bounds is {0.000000,0.000000} 203.000000 x 17.000000
WHCCConnect[26458:f07] TextField size is {0.000000,0.000000} 100.000000 x 17.000000
WHCCConnect[26458:f07] cell string value is now hello row!

and the resulting table looks like this:

enter image description here

What am I doing wrong? How can I get these blasted rows to size properly?

  • 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-15T01:26:41+00:00Added an answer on June 15, 2026 at 1:26 am

    Did you try delegate method:

    - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am experiencing a problem with Swing that only occurs when the computer monitor
I am experiencing a problem with my circularlinkedlist. it is a list, that is
I'm experiencing an insane problem... A simple Cocoa application with QTMovieView , in which
I'm experiencing a problem with my VBA application. I need to define a Recordset
I am experiencing a problem with my app. The 1st screen that appears is
I'm experiencing a problem with Cufon text-replacement library. Take a look at: http://www.dgform.com/new/ Next
i am currently experiencing a problem were i get *** glibc detected *** ./efit:
I am experiencing a problem with some Javascript - please see my site and
I'm experiencing a problem inserting values into a SQLite database. The data I download
I am experiencing this problem with Node.js express framework 3.0: https://github.com/visionmedia/express/issues/1187 I've been using

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.