2012-03-23 68 views
0

這裏是我用的第一個表格單元格犯規顯示附屬箭頭掙扎的代碼,但其他表格單元做工精細...第一的UITableViewCell的附帶箭頭沒有顯示

下面是桌子小區1碼,其他細胞也是定製的,但工作正常。

- (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]; 
} 

下面是視圖控制器代碼:

 
- (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; 
} 

+0

@MarkGranoff,非常感謝幫助我格式化我發佈的凌亂代碼:) – trillions 2012-03-23 18:55:39

+0

沒問題。只需將它放在

標籤之間即可。 –
                        
                            
                                2012-03-23 18:59:46
                            
                        
                    

+0

你是否輸入了這段代碼?這個代碼不是以這樣一種好的方式寫的......理想情況下,你不應該在「if」和另一個「外部」中放置一個「返回」。 – TommyG 2012-03-23 19:07:27

回答

1

電話[超級layoutSubviews]從你的重寫layoutSubviews內。

+0

上帝,你救了我!這正是我錯過的!非常感謝!!^____ ^ – trillions 2012-03-23 22:07:37