Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit cdaa5c8685b18994e7e09a3e7a93befbd4981be8 1 parent 2733e2d
@diederich diederich authored jverkoey committed
Showing with 20 additions and 3 deletions.
  1. +20 −3 src/Three20UI/Sources/TTTableImageItemCell.m
View
23 src/Three20UI/Sources/TTTableImageItemCell.m
@@ -67,6 +67,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 -
#pragma mark TTTableViewCell class public
@@ -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;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.