2011-03-25 42 views
2

我想將UITableView的部分標題推送到另一個視圖控制器的部分標題。 但我無法想出一種方法來讀取現有的部分標題。現有的部分標題是動態構建的,我寧願重複使用它,而不是重新構建它。讀取UITableView的字符串值部分標題

if (indexPath.section == 0) { 

     SecondViewController *secondViewController = [[SecondViewController alloc] init]; 
     secondViewController.strValueHolder = FOO_section.sectionTitle; // FOO Code 
     [[self navigationController] pushViewController:secondViewController animated:YES]; 
     [secondViewController release]; 

} 

回答

8

可以調用titleForHeaderInSection方法直接:

NSString *sectionTitle = 
    [self tableView:tableView titleForHeaderInSection:indexPath.section]; 

或titleForHeaderInSection打動你目前擁有的代碼,自定義方法,並呼籲從titleForHeaderInSection是自定義的方法,並在那裏你正在推動的另一個地方視圖控制器。

+0

謝謝你的迴應。我選擇了第二種選擇,使用自定義方法並從多個地方調用它。 – 2011-03-28 13:22:56