I would like to add a custom UITabBar implementation to a UITableViewCell.
If a UITableViewCell was itself a UIViewController I could use view controller containment, but it isn't.
The best I can do right now is add the TabBar's view to the contentView of the cell in cellForRowAtIndexPath:
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
NSString *cellID;
UITableViewCell *cell;
cellID = @"TabCell";
cell = [tableView dequeueReusableCellWithIdentifier:cellID] ?: [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
cell.contentView.backgroundColor = UIColor.blueColor;
UITabBarController *tabBarController = [[UITabBarController alloc] init];
UIViewController *vc1 = [UIViewController new];
vc1.view.backgroundColor = UIColor.magentaColor;
vc1.title = @"TAB1";
UIViewController *vc2 = [UIViewController new];
vc2.view.backgroundColor = UIColor.purpleColor;
vc2.title = @"TAB2";
tabBarController.delegate = self;
tabBarController.viewControllers = @[vc1, vc2];
[cell.contentView addSubview:tabBarController.view];
return cell
}
The problem is that the cell only shows the view of the TabBar and not the TabBar control itself.
How can I show the entire TabBar in a UITableViewCell?