你必須子類化tableViewController,最終彈出到導航控制器堆棧。在子類型tableViewController的內部,你應該有一個數組(或其他數據結構)來保存相關信息,並且應該公開(使用@synthesize)。然後,在初始化新的tableView之後,但在將其推入堆棧之前,請設置數組。例如,在你的RootViewController.m:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath {
SubmenuViewController *svc = [[SubmenuViewController alloc] initWithStyle:UITableViewStyleGrouped];
svc.arr = someArray; //this array holds your entire Submenu, this should be based on whatever the user selected in newIndexPath.row
[svc setTitle:@"Some Title"];
[self pushViewController:svc animated:YES];
}
由於SubmenuViewController是的UITableViewController的子類中,(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
裏,你將返回基於ARR陣列上的正確的單元格。
編輯:我要指出的是,在我的例子,RootViewController的子類的UINavigationController
此鏈接可能對您有用http://cocoadevcentral.com/d/learn_objectivec/ – Altealice 2011-03-14 18:13:33