UITableView详细信息视图控制器

时间:2012-03-13 04:25:49

标签: iphone objective-c ipad

我在分割视图应用程序中有表视图我希望每个我有不同的视图控制器。例如,一行我有cal而另一行是电脑等所以对于这两种我可能有不同的看法,点击它们我可能会得到理想的视图

我在拆分视图中为表视图执行了以下代码

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section        {
GCRetractableSectionController* sectionController = [self.retractableControllers   objectAtIndex:section];
return sectionController.numberOfRow;
  }

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
   GCRetractableSectionController* sectionController = [self.retractableControllers    objectAtIndex:indexPath.section];
     return [sectionController cellForRow:indexPath.row];
       }

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath  *)indexPath {


     GCRetractableSectionController* sectionController = [self.retractableControllers objectAtIndex:indexPath.section];

        if(indexPath.section == 0){
        if(indexPath.row == 0){
            return [sectionController didSelectCellAtRow:indexPath   viewController:detailViewController withData:@""];
       }
      else {
       return [sectionController didSelectCellAtRow:indexPath viewController:detailViewController withData:[generalCalculatorArray   objectAtIndex:indexPath.row - 1]];
       }
    }
     else if(indexPath.section == 1){
    if(indexPath.row == 0){
    return [sectionController didSelectCellAtRow:indexPath viewController:detailViewController withData:@""];
    }
      else {
       return [sectionController didSelectCellAtRow:indexPath viewController:detailViewController withData:[cardiologyArray objectAtIndex:indexPath.row -  1]];
     }

  }
 }

1 个答案:

答案 0 :(得分:0)

Apple有你想要的例子,Here You Go或者你只需​​要准确地知道 然后继续阅读

NSArray *viewControllers = [[NSArray alloc] initWithObjects:self.navigationController, detailViewController, nil];

上面一行中的 detailViewController 表示要更改的详细视图控制器的实例。在更改Detail view cont时,需要更新拆分视图控制器的视图控制器数组

splitViewController.viewControllers = viewControllers;
[viewControllers release];

希望这对你有所帮助。如果不提出评论请。