2016-08-23 33 views
0

我想表现出的tableView到像细胞:如何将一个tableView添加到目标c中的CellView?

_____________________________________ 
| (IMAGE) ______________    | --CELL 0 

|   | MyCustomText|--CELL 0.0 | 
|   |_____________|    | 
|   |MyCustomText2|--CELL 0.1 | 
|   |_____________|    | 
|          | 
|          | 
    -------------------------------------- 
    _____________________________________ 
| (IMAGE) 2       | --CELL 1 
    -------------------------------------- 

我想在故事板上添加的tableView然后连接一个新的TableviewController并用新CustomCellTableView,但是这并不表明在该行的表什么。

有可能吗?我如何声明viewController或不需要添加ViewController?

谢谢!

+0

你需要一个CELL0的内容是滚动(witouth中的tableView的其余部分滚动)?如果否,'UITableView'可以管理不同类型的单元。您可以有两个自定义单元格,一个用于cell0,另一个用于celle1。 – Larme

+0

问题需要一点清楚,并添加示例图像请 – Spynet

+0

可能的重复[是否有可能在UITableViewCell中添加UITableView](http://stackoverflow.com/questions/17398058/is-it-possible-to-add -uitableview中之-的UITableViewCell) – Sandy

回答

0

我认为你不需要一个新的tableview控制器。在你的表格单元格中,你可以添加另一个tableview。

@interface ImageCell : UITableViewCell<UITableViewDataSource,UITableViewDelegate> 

@property (retain, nonatomic) IBOutlet UITableView *abc; 

@end 

并像往常一样实施数据源和委托方法。

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 1; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; 

    // Configure the cell... 

    return cell; 
} 
0
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ 
    if (tableView == self.tableView) { 
     return 8; 
    } else { 
     return 3; 
    } 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell; 
    if (tableView == self.tableView) { 
     cell = [self.tableView dequeueReusableCellWithIdentifier:@"cell"]; 
     if (cell == nil) { 
      cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 
     } 
     if (indexPath.row == 0) { 
      self.childTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, 100)]; 
      self.childTableView.delegate = self; 
      self.childTableView.dataSource = self; 
      [cell.contentView addSubview:self.childTableView]; 
     }else { 
      cell.textLabel.text = @"Pavan"; 
     } 
    } else if (tableView == self.childTableView){ 
     cell = [self.tableView dequeueReusableCellWithIdentifier:@"childCell"]; 
     if (cell == nil) { 
      cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"childCell"]; 
     } 
     cell.textLabel.text = @"hi"; 
    } 
    return cell; 
} 

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { 
    if (tableView == self.tableView) { 
     if (indexPath.row == 0) { 
      return 250; 
     } else { 
      return 100; 
     } 
    } else { 
     return 50; 
    } 
} 
相关问题