2011-12-17 117 views
0

我有一個案例,但detailtext沒有顯示?有誰知道問題是什麼?Detailtext沒有顯示的情況下?

我用:UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UIViewController *controller;   
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
    switch(indexPath.row) { 
     case 0: 
     { 
      NSLog(@"Case 0"); 
      controller = [[wed1 alloc] init]; //WithStyle:UITableViewStylePlain]; 
      [self.navigationController pushViewController:controller animated:YES]; 
      cell.detailTextLabel.text = @"Wedstrijden!"; 
     } 
      break; 

回答

1
case 0: 
    { 
     NSLog(@"Case 0"); 

     controller = [[wed1 alloc] init]; //WithStyle:UITableViewStylePlain]; 

//創建控制器

 [self.navigationController pushViewController:controller animated:YES]; 

//在他的觀點,你是顯示下一個視圖控制器的看法

 cell.detailTextLabel.text = @"Wedstrijden!"; 

//在這裏你是changi納克文字當前的tableView的單元格的文本(這實際上是將要關閉屏幕作爲新的控制器視圖將前面的語句執行後顯示)

} 

與一段代碼您共享 - 我不在這裏發現任何錯誤,細節文本不應該是可見的,因爲這個視圖將會消失。

0

我不完全明白爲什麼在推送新的視圖控制器後,您希望在單元格上設置詳細文本。正如samfisher所說,當用戶按下第一個單元格時,如果是0,新的視圖控制器將被分配,初始化然後被推入,之後您將詳細文本設置爲「Wedstrijden」。

我假設你可能只是混淆了使用哪個屬性。我對你的問題是:何時何地你想要這段文字出現?

0

如果使用樣式UITableViewCellStyleDefault創建單元格,則不會顯示詳細文本標籤。在tableView:cellForRowAtIndexPath:實現中,您可以創建樣式爲UITableViewCellStyleSubtitleUITableViewCellStyleValue1的單元。

相關問題