6

Here is the code I am struggling with, the first table cell doesnt display the accessary arrow, but other table cells work fine...

Below is the code for table cell1, other cells is also customized but work fine.

- (void) initialization { labelTitle = [[UILabel alloc] initWithFrame:CGRectZero]; labelTitle.font = [UIFont fontForMoreLikeResultTitle]; labelTitle.textColor = [UIColor blackColor]; labelTitle.numberOfLines = 1; labelTitle.lineBreakMode = UILineBreakModeTailTruncation; labelTitle.backgroundColor = [UIColor clearColor]; labelFulLAddress = [[UILabel alloc] initWithFrame:CGRectZero]; labelFulLAddress.font = [UIFont fontForMoreLikeResultDescription]; labelFulLAddress.textColor = [UIColor blackColor]; labelFulLAddress.numberOfLines = 1; labelFulLAddress.lineBreakMode = UILineBreakModeTailTruncation; labelFulLAddress.backgroundColor = [UIColor clearColor]; [[self contentView] addSubview:labelTitle]; [[self contentView] addSubview:labelFulLAddress]; } - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // Initialization code [self initialization]; } return self; } - (void) layoutSubviews { float xOffset = 20.0f; float yOffset = 10.0f; float currentUsedHeight = yOffset; labelTitle.text = documentTitle; labelTitle.frame = CGRectMake(xOffset, currentUsedHeight, 320.0f - 2 * xOffset, 60.0f); [labelTitle sizeToFitHeight]; [labelTitle sizeToFitWidth]; labelFulLAddress.text = @"99999 Bellevue Way NE, Bellevue WA"; currentUsedHeight += (yOffset + labelTitle.frame.size.height); labelFulLAddress.frame = CGRectMake(xOffset, currentUsedHeight, 320.0f - 2 * xOffset, 60.0f); [labelFulLAddress sizeToFitHeight]; [labelFulLAddress sizeToFitWidth]; } 

Below is the code in view controller:

 - (UITableViewCell *) createResultTableCell1:(UITableView *)tableView { static NSString *CellIdentifier = @"FirstMoreLikeResultCell"; FirstResultTableCell *cell = (FristResultTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[MoreLikeTableCell1 alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; } cell.documentTitle = self.documentTitle; return cell; } - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell; if (indexPath.row == 0) { cell = [self createResultTableCell1:tableView]; } else { cell = [self createResultTableCell2:tableView cellForRowAtIndexPath:indexPath]; } return cell; } 
12
  • @MarkGranoff, thanks a lot for helping me formatting the messy code I posted :) Commented Mar 23, 2012 at 18:55
  • No problem. Just put it between <pre></pre> tags. Commented Mar 23, 2012 at 18:59
  • are you entering this code at all? this code is not written in such a good way...ideally you should not place one "return" inside an "if" and the other one outside. Commented Mar 23, 2012 at 19:07
  • Let's see the code for your UITableViewCells. Maybe something going on there? Commented Mar 23, 2012 at 19:49
  • @TommyG yes, the code wasn't clean, but i just cleaned it and updated it. Commented Mar 23, 2012 at 20:24

1 Answer 1

7

Call [super layoutSubviews] from within your overridden layoutSubviews.

Sign up to request clarification or add additional context in comments.

1 Comment

god, you saved me! It's exactly what I missed! Thanks a lot!! ^____^

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.