Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread Display Modes
Old Nov 8, 2012, 10:50 PM   #1
macrumors regular
Join Date: Apr 2011
View based table view layout woes

I'm working on my app that's mainly for displaying tweets, and I've been trying to get it to properly layout multiple NSTextView-s (without scroll views) inside a table cell view, and the results have been unpleasant:

(The red rectangle is something I added so I can see the bounds of the text view - it's a debugging visual aid.)

Expanding the window seems to fix that:

I, however, would like to know why this is happening. My code for calculating the sizes is pretty straight forward - in the end of my viewForTableColumn:row: method I have this:

const CGFloat BaseHeight = 20.0;
    const CGFloat Margin = 0.0;
    const CGFloat Width = self.tableView.frame.size.width;
    const CGFloat DateHeight = [dateAttributedString boundingRectWithSize:NSMakeSize(Width, 0) options:NSStringDrawingUsesLineFragmentOrigin].size.height;
    const auto NewViewHeight = [tweetAttributedString boundingRectWithSize:NSMakeSize(Width, 0) options:NSStringDrawingUsesLineFragmentOrigin].size.height;
    const CGFloat NewHeight = BaseHeight + NewViewHeight + Margin + DateHeight;
    TweetManager->items[row].row_height = NewHeight;
    [tableView noteHeightOfRowsWithIndexesChanged:[NSIndexSet indexSetWithIndex:row]];
    return view;
And my heightOfRow: is:

- (CGFloat) tableView: (NSTableView*) TableView heightOfRow: (int) Row
    const CGFloat MinimumSize = 54.0;
    if(!TweetManager) return MinimumSize;
    const CGFloat Offset = 6.0;
    return max(TweetManager->items[Row].row_height, MinimumSize) + Offset;
What could possibly be going wrong there? I'm stumped. Any help would be greatly appreciated.
Starfox is offline   0 Reply With Quote

MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 06:20 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC