Created
August 20, 2011 18:47
-
-
Save mrjjwright/1159482 to your computer and use it in GitHub Desktop.
Calculate height for a given row
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (CGFloat)tableView:(TUITableView *)tableView heightForRowAtIndexPath:(TUIFastIndexPath *)indexPath | |
{ | |
CGFloat calcuatedHeight = 55.0; | |
NSDictionary *post = [_posts objectAtIndex:indexPath.row]; | |
NSString *type = [post valueForKey:@"type"]; | |
NSString *message = [post valueForKey:@"message"]; | |
if (!message) message = type; | |
TUIAttributedString *s = [TUIAttributedString stringWithString:message]; | |
[s setAlignment:TUITextAlignmentLeft lineBreakMode:TUILineBreakModeWordWrap]; | |
s.color = [TUIColor blackColor]; | |
s.font = [Crew crewFont]; | |
CGFloat textHeight = [s ab_sizeConstrainedToWidth:200].height; | |
NSLog(@"%f", textHeight); | |
if (textHeight > calcuatedHeight) calcuatedHeight = textHeight; | |
return calcuatedHeight; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment