2011-08-29 67 views
0

我有一個導航應用程序,有一個部分,您可以定義您的搜索參數,基本上是自定義單元格做不同的事情(uitextview,開關和標籤)的uitableview如何設置從一個uitableviewcell選擇子視圖的標題

我想要做的是,當用戶從tableview中選擇一個單元格時,它會打開一個新的uitableview,當該視圖打開時,它將通過php向我的數據庫發送一個請求,並獲得一個xml響應,那種觀點。不過,我只想在前一個視圖中爲一些不同的單元格選擇使用一個uitableview。我想知道是否可以在選擇父視圖單元格時指定子視圖的標題。

我希望能夠解釋我正在努力實現的目標......如果這不是做事情的方式,可以讓我知道..但是從我一直在做的事情來看,我認爲這是做事的正確方法。

**更新 我現在想弄清楚如何根據關被按下電池定義標題,我試圖做這樣的事情..

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

    SearchResponseTableViewController *searchResponseTableViewController = [[SearchResponseTableViewController alloc] initWithNibName:@"SearchResponseTableViewController" bundle:nil]; 
    // ... 
    // Pass the selected object to the new view controller. 
    [self.navigationController pushViewController:searchResponseTableViewController animated:YES]; 
    if (indexPath = 1,3) { //<<--- not sure what to do here or if its possible 
     searchResponseTableViewController.title = @"manufacture"; 
    } 
    [searchResponseTableViewController release]; 

} 

回答

1

簡單:你推前在didSelectRowAtIndexPath:中查看您指定的標題,這是視圖控制器的屬性。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    //... 
    SubViewController *controller = [[SubViewController alloc] init]; 
    controller.title = @"Whatever"; 
    [self.navigationController pushViewController:controller animated:YES]; 
} 
+0

我會用if(section = 0),if(indexPath.row == 2)等來爲不同的單元格指定不同的controller.title嗎? –

+0

如何根據新視圖使用indexpath定義不同的標題? –

+0

對,這就是爲什麼我把'// ...'。你會檢查'indexPath'並分配合適的標題。 – Mundi

相關問題