Skip to content

Commit

Permalink
Includes link URLs as subtitles in Links module.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinanderson committed Oct 1, 2012
1 parent 4e60697 commit 36fb9c7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Modules/Links/LinksViewController.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -183,14 +183,15 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
UITableViewCell *cell = nil; UITableViewCell *cell = nil;
cell = [tableView dequeueReusableCellWithIdentifier:reuseID]; cell = [tableView dequeueReusableCellWithIdentifier:reuseID];
if (!cell) { if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseID] autorelease]; cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseID] autorelease];
} }


NSDictionary *section = [self.linkResults objectAtIndex:indexPath.section]; NSDictionary *section = [self.linkResults objectAtIndex:indexPath.section];
NSArray *links = [section objectForKey:kLinksKeySectionLinks]; NSArray *links = [section objectForKey:kLinksKeySectionLinks];
NSDictionary *currentLink = [links objectAtIndex:indexPath.row]; NSDictionary *currentLink = [links objectAtIndex:indexPath.row];


cell.textLabel.text = [currentLink objectForKey:kLinksKeyLinkTitle]; cell.textLabel.text = [currentLink objectForKey:kLinksKeyLinkTitle];
cell.detailTextLabel.text = [currentLink objectForKey:kLinksKeyLinkUrl];


cell.accessoryView = [UIImageView accessoryViewWithMITType:MITAccessoryViewExternal]; cell.accessoryView = [UIImageView accessoryViewWithMITType:MITAccessoryViewExternal];


Expand Down Expand Up @@ -227,12 +228,15 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa
NSDictionary *currentLink = [links objectAtIndex:indexPath.row]; NSDictionary *currentLink = [links objectAtIndex:indexPath.row];


NSString *title = [currentLink objectForKey:kLinksKeyLinkTitle]; NSString *title = [currentLink objectForKey:kLinksKeyLinkTitle];
NSString *url = [currentLink objectForKey:kLinksKeyLinkUrl];


CGFloat padding = 10.0f; CGFloat padding = 10.0f;
CGFloat linkTitleWidth = CGRectGetWidth(tableView.bounds) - (3 * padding + 39); // padding on each side due to being a grouped tableview + padding on left + 39px of accessory view on right CGFloat linkTitleWidth = CGRectGetWidth(tableView.bounds) - (3 * padding + 39); // padding on each side due to being a grouped tableview + padding on left + 39px of accessory view on right
CGSize titleSize = [title sizeWithFont:[UIFont fontWithName:BOLD_FONT size:CELL_STANDARD_FONT_SIZE] constrainedToSize:CGSizeMake(linkTitleWidth, 100) lineBreakMode:UILineBreakModeWordWrap]; CGSize titleSize = [title sizeWithFont:[UIFont fontWithName:BOLD_FONT size:CELL_STANDARD_FONT_SIZE] constrainedToSize:CGSizeMake(linkTitleWidth, 2000) lineBreakMode:UILineBreakModeWordWrap];

CGSize urlSize = [url sizeWithFont:[UIFont fontWithName:STANDARD_FONT size:CELL_DETAIL_FONT_SIZE] constrainedToSize:CGSizeMake(linkTitleWidth, 2000) lineBreakMode:UILineBreakModeTailTruncation];


return MAX(titleSize.height + 2 * padding, tableView.rowHeight); return MAX(titleSize.height + urlSize.height + 2 * padding, tableView.rowHeight);
} }


#pragma mark - Table View Delegate #pragma mark - Table View Delegate
Expand Down

0 comments on commit 36fb9c7

Please sign in to comment.