2010-11-02 19 views
0

我試圖在我的tableView中顯示一些文本爲subtitleUITableViewCellStyleSubtitle顯示不正確

這裏是我的代碼爲tableView的一部分:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier]; 

    if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier] autorelease]; } //did the subtitle style 

     NSUInteger row = [indexPath row]; 
     cell.textLabel.text = [listData objectAtIndex:row]; 
     return cell; 

     cell.detailTextLabel.text = @"Hello there"; //This is not displaying... 
    } 
} 

是否有任何理由爲什麼我沒有看到字幕文本,當我運行?

回答

19
return cell; 

cell.detailTextLabel.text = @"Hello there"; //This is not displaying... 

您設置detailTextLabel後您return細胞。當你return你離開方法的單元格。因此最後一行代碼沒有運行。

+0

噢,呃,它立即修復它。剛剛吹過我......謝謝! :) – 2010-11-02 22:20:09

+3

@willingfamily:你應該打這個答案接受。 – 2010-11-02 23:04:51