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

Similar Threads
thread Thread Starter Forum Replies Last Post
Table View to Detail View hammy35 iPhone/iPad Programming 3 Apr 16, 2014 01:33 AM
View-based table view losing selection highlight Starfox Mac Programming 1 Nov 28, 2012 01:02 AM
Find location of table view cell that calls view controller moonman239 iPhone/iPad Programming 3 Nov 24, 2012 05:31 PM
Pushing to a Detail View from a Table View Cell using Xcode Storyboard xcodeApp10 iPhone/iPad Programming 2 Sep 17, 2012 03:45 PM
Idea: View-Based Notifications (Instead of Focus-Based) faroZ06 OS X 10.8 Mountain Lion 0 Jul 28, 2012 12:32 PM

Forum Jump

All times are GMT -5. The time now is 02:56 PM.

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

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2015, MacRumors.com, LLC