2010-11-09 72 views
0

點擊我有一個Xcode iPhone項目設置與下列查看時將不會顯示:中的詳細信息的TableView行

我的應用委託創建一個動態tabBarController並增加了兩個視圖控制器它。其中一個包含一個TableView。

從該TableView中,我希望用戶能夠單擊每個項目上的藍色箭頭按鈕並獲取有關它的更多詳細信息。這是一個相當標準的東西......這是我必須做的,代碼:眼下

-(void)tableView: (UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *) indexPath { 
    [self tableView:tableView didSelectRowAtIndexPath:indexPath]; 
} 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    // Navigation logic may go here. Create and push another view controller. 
    [tableView deselectRowAtIndexPath:indexPath animated:NO]; 

     if (self.switchView == nil) { 
      SwitchViewController *viewController = [[SwitchViewController alloc] initWithNibName:@"SwitchViewController" bundle:[NSBundle mainBundle]]; 
      self.switchView = viewController; 
      [viewController release];  
     } 

    [self.navigationController pushViewController:self.switchView animated:YES]; 
    self.switchView.title = @"Test Title"; 

} 

,我SwitchViewController是什麼,但上面有一個按鈕一個空白視圖。 當用戶點擊藍色按鈕時,沒有任何反應。我可以放入一個斷點並查看所有正在執行的代碼,但iPhone屏幕根本不會更改。

任何提示?我確定這是基本的,因爲我對iOS開發很新穎。

在此先感謝!

[R

+1

你是否檢查過navigationController不是零?您還沒有提到您的層次結構中的任何UINavigationControllers ... – Vladimir 2010-11-09 13:52:15

+0

同時檢查'viewController'以確保它正在從NIB正確實例化。 – kubi 2010-11-09 14:02:16

+0

@Vladimir - 我沒有專門設置一個「導航控制器」,我剛纔假設我的當前視圖*是導航控制器。該代碼所在的tableview頁面從UITableViewController繼承。瞭解一篇文章,提供有關實際導航控制器設置的更多詳細信息? – bugfixr 2010-11-09 14:07:51

回答

0

從你的答案弗拉基米爾·在評論問題很明顯你沒有一個UINavigationController初始化。所以試試這樣:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:tableViewController]; 

然後添加navController到您的tabBarController而不是tableViewController。