0

I want show a tableView into a cell like:

 _____________________________________
 | (IMAGE) ______________              | --CELL 0   

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

I'm trying add a tableView in storyboard and then connect with a new TableviewController and with a new CustomCellTableView, but this not show anything in the row's table.

It's possible? How can I declare the viewController or needn't add ViewController?

Thanks!

user3745888
  • 6,143
  • 15
  • 48
  • 97
  • Do you need that the content of cell0 to be scrollable (witouth the rest of the tableView to scroll)? If no, the `UITableView` can manage cells of different type. You can have two custom cells, one for the cell0, and another one for the celle1. – Larme Aug 24 '16 at 08:02
  • question need to little bit clear and add the sample image please – Arun Aug 24 '16 at 09:56
  • Possible duplicate of [Is it possible to add UITableView within a UITableViewCell](http://stackoverflow.com/questions/17398058/is-it-possible-to-add-uitableview-within-a-uitableviewcell) – Sanoj Kashyap Aug 24 '16 at 09:56

2 Answers2

0

I think you don't need a new tableview controller. In your table cell, you can add another tableview.

@interface ImageCell : UITableViewCell<UITableViewDataSource,UITableViewDelegate>

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

@end

and implement datasource and delegate method as usual.

#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;
}
Aye
  • 265
  • 1
  • 3
  • 13
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;
    }
}
Sanoj Kashyap
  • 5,020
  • 4
  • 49
  • 75
Pavankumar
  • 288
  • 1
  • 10
  • Is the datasource for the second TableView the same as first TableView ? For me if i set the data source to the ViewController the app crashed. – TheAlphaGhost Feb 19 '19 at 14:08