Cocoanetics/DTCoreText — Issue #102: DTAttributedTextContentView setFrame behavior not normal
Author: gshaviv
Created: 2012-01-09 07:01:35+00:00
State: open

I have a code where I determine the size needed for the DT...View and then position it, e.g:
'''C
CGSize sz = [aView suggestedFrameSizeToFitEntireStringConstraintedToWidth:neededWidth];
aView.frame = CGRectMake(someX,someY,sz.width,sz.height);
NSLog(@"aView.h=%.0f sz.h=%.0f",aView.frame.size.height,sz.size.height);
'''
I find that on many occasions there is a few pixel difference between the height I set the view to the height it gets. This causes several issues:
* It's not standard UIKit behavior, a view should get the frame size it is assigned.
* It screws up fine layout algorithms. e.g. I want the bottom of the view frame to be at a certain Y but the bottom often is not there even though I calculated it to be there since the re-position algorithm of the view is always to preserve the top-left.
* Why does suggestedFrameSizeToFitEntireStringConstraintedToWidth: not return the accurate height needed?

My workaround is to set the view frame to the needed width and infinite height, then reposition it based on what frame size it actually got. But this is a hack and shouldn't be needed.