Permalink
Browse files

[UI] Fix height calculation of TTTableImageItems

Factored out method to choose the font and use that for height
calculations and in setObject.
  • Loading branch information...
diederich authored and jverkoey committed Feb 25, 2011
1 parent 2733e2d commit cdaa5c8685b18994e7e09a3e7a93befbd4981be8
Showing with 20 additions and 3 deletions.
  1. +20 −3 src/Three20UI/Sources/TTTableImageItemCell.m
@@ -64,6 +64,23 @@ - (void)dealloc {
}
+///////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////////////////
+#pragma mark -
+#pragma mark Private helpers
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
++ (UIFont*)fontForImageItem:(id)imageItem {
+ if ([imageItem isKindOfClass:[TTTableRightImageItem class]]) {
+ return TTSTYLEVAR(tableSmallFont);
+
+ } else {
+ return TTSTYLEVAR(tableFont);
+ }
+}
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
@@ -96,7 +113,7 @@ + (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(id)object {
CGFloat maxWidth = tableView.width - (imageWidth + kTableCellHPadding*2 + kTableCellMargin*2);
- CGSize textSize = [imageItem.text sizeWithFont:TTSTYLEVAR(tableSmallFont)
+ CGSize textSize = [imageItem.text sizeWithFont:[self fontForImageItem:imageItem]
constrainedToSize:CGSizeMake(maxWidth, CGFLOAT_MAX)
lineBreakMode:UILineBreakModeTailTruncation];
@@ -206,12 +223,12 @@ - (void)setObject:(id)object {
_imageView2.defaultImage = item.defaultImage;
_imageView2.urlPath = item.imageURL;
+ self.textLabel.font = [[self class] fontForImageItem:item];
+
if ([_item isKindOfClass:[TTTableRightImageItem class]]) {
- self.textLabel.font = TTSTYLEVAR(tableSmallFont);
self.textLabel.textAlignment = UITextAlignmentCenter;
self.accessoryType = UITableViewCellAccessoryNone;
} else {
- self.textLabel.font = TTSTYLEVAR(tableFont);
self.textLabel.textAlignment = UITextAlignmentLeft;
}
}

0 comments on commit cdaa5c8

Please sign in to comment.