No need to use an @IBInspectable
. You can simply use each table source within the UITableViewDelegate
methods conditionally. Here's one way to go about doing this:
First within your storyboard's UITableViewController
, add a prototype cell, then within that prototype cell add a UITableView
with its own prototype cell.
Then set both the inner and outer table view cell's reuse identifiers like so:
Outer table view cell:

Inner table view cell:

Then link that inner tableview's data source and delegate to the UITableViewController
's own data source and delegate:

Then within your UITableViewController
class, you can set your tables' elements conditionally, for example:
- (void)viewDidLoad {
[super viewDidLoad];
dataSource1 = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", nil];
dataSource2 = [NSArray arrayWithObjects:@"a", @"b", @"c", nil];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (tableView == self.tableView) {
return 80;
} else {
return 20;
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
if (tableView == self.tableView) {
return dataSource1.count;
} else {
return dataSource2.count;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
if (tableView == self.tableView) {
cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];
} else {
cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier2" forIndexPath:indexPath];
}
// Configure the cell...
if (tableView == self.tableView) {
cell.textLabel.text = [dataSource1 objectAtIndex:indexPath.row];
} else {
cell.textLabel.text = [dataSource2 objectAtIndex:indexPath.row];
cell.backgroundColor = [UIColor blueColor];
}
cell.textLabel.backgroundColor = [UIColor clearColor];
return cell;
}
Which in this case produces the following result:
