|
|
#1 |
|
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:
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;
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;
}
|
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 08:09 PM.






Linear Mode
