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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:24:55+00:00 2026-05-15T15:24:55+00:00

I have an NSTableView in my application with data being drawn in for both

  • 0

I have an NSTableView in my application with data being drawn in for both the X and Y axes (ie, every row is matched with every column.) I’ve got the data populating the cells the way I’d like, but it looks terrible with the columns stretched out horizontally.

I would like to turn the NSTextFieldCell on its side, so that the text is written vertically instead of horizontally. I realize that I’m probably going to have to subclass the NSTextFieldCell, but I’m not sure which functions I’m going to need to override in order to accomplish what I want to do.

What functions in NSTextFieldCell draw the text itself? Is there any built-in way to draw text vertically instead of horizontally?

  • 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-15T15:24:56+00:00Added an answer on May 15, 2026 at 3:24 pm

    Well, it took a lot of digging to figure this one out, but I eventually came across the NSAffineTransform object, which apparently can be used to shift the entire coordinate system with respect to the application. Once I had figured that out, I subclassed NSTextViewCell and overrode the -drawInteriorWithFrame:inView: function to rotate the coordinate system around before drawing the text.

    - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
        // Save the current graphics state so we can return to it later
        NSGraphicsContext *context = [NSGraphicsContext currentContext];
        [context saveGraphicsState];
    
        // Create an object that will allow us to shift the origin to the center
        NSSize originShift = NSMakeSize(cellFrame.origin.x + cellFrame.size.width / 2.0,
                                        cellFrame.origin.y + cellFrame.size.height / 2.0);
    
        // Rotate the coordinate system
        NSAffineTransform* transform = [NSAffineTransform transform];
        [transform translateXBy: originShift.width yBy: originShift.height]; // Move origin to center of cell
        [transform rotateByDegrees:270]; // Rotate 90 deg CCW
        [transform translateXBy: -originShift.width yBy: -originShift.height]; // Move origin back
        [transform concat]; // Set the changes to the current NSGraphicsContext
    
        // Create a new frame that matches the cell's position & size in the new coordinate system
        NSRect newFrame = NSMakeRect(cellFrame.origin.x-(cellFrame.size.height-cellFrame.size.width)/2,
                                     cellFrame.origin.y+(cellFrame.size.height-cellFrame.size.width)/2,
                                     cellFrame.size.height, cellFrame.size.width);
    
        // Draw the text just like we normally would, but in the new coordinate system
        [super drawInteriorWithFrame:newFrame inView:controlView];
    
        // Restore the original coordinate system so that other cells can draw properly
        [context restoreGraphicsState];
    }
    

    I now have an NSTextCell that draws its contents sideways! By changing the row height, I can give it enough room to look good.

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

Sidebar

Related Questions

I have an NSTableView that is populating with my data source. My data model
I have a classic CoreData application, displaying it's data in NSTableView with Binding (all
In my small Core Data application I have some NSTableView views binded with NSArrayController
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 custom NSTableView subclass which is bound to a data source (an
Current Situation: Direct Binding I have an NSTableView which displays the data that comes
I have an application with a view-based NSTableView in it. Inside this table view,
i have NSTableView and two columns in it: NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@custId]
I have a non document-based Core Data application. There's an NSTreeController that manages a

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.