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:
http://www.flickr.com/photos/59098813@N06/8168587403/
(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:
http://www.flickr.com/photos/59098813@N06/8168616078/
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:
And my heightOfRow: is:
What could possibly be going wrong there? I'm stumped. Any help would be greatly appreciated.
http://www.flickr.com/photos/59098813@N06/8168587403/
(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:
http://www.flickr.com/photos/59098813@N06/8168616078/
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:
Code:
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:
Code:
- (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.