On Tue, Aug 6, 2013, at 02:21 AM, Diederik Meijer | Ten Horses wrote: > The way is handled something similar is by first calculating the label > size for the dynamic string (which you probably need anyway), then using > the returned value in the heightForHeaderInSection (or recalculating it > with a method call), followed by calling reloadData on the tableView.
You're calling -reloadData just to load a header/footer view? That's overkill. > -(float)calculateLabelSizeHeightForText:(NSString *)text { > CGSize constraintSize = ([[UIDevice currentDevice] > userInterfaceIdiom] == UIUserInterfaceIdiomPad) ? CGSizeMake(748.0f, > MAXFLOAT) : CGSizeMake(300.0f, MAXFLOAT); Why are you hardcoding sizes here? This will only work if the table view you're inserting into has a contentSize.width of your magic values. Since you know what table view you're being asked for the cell heights for, why not just use the table view's contentSize.width? > //You will need to define kDefaultCellFont > CGSize labelSize = [text sizeWithFont:[UIFont systemFontOfSize:14] > constrainedToSize:constraintSize > lineBreakMode:UILineBreakModeWordWrap]; > return labelSize.height+10; > } Rather than fudge factors, why not use auto layout? Then you don't have to duplicate layout information between the nib and your code. Jon Wight from Twitter has put together an example of how to use auto layout to compute cell heights: https://github.com/schwa/Smart-Tables --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com