I want to load a UITableViewController inside a UIView because I want to change the view on button click (like UITabBar but with my own buttons). I’m using a storyboard and have defined a TableViewController with custom class “InitialTableViewController” and identifier “InitialView”.
My code look like this:
#import "MyViewController.h"
#import "InitialTableViewController.h"
@interface MyViewController ()
@end
@implementation MyViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
InitialTableViewController *tableControl = [self.storyboard instantiateViewControllerWithIdentifier:@"InitialView"];
[[self view] addSubview:[tableControl view]];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
@end
The view starts and I can see my table but the code inside “InitialTableViewController” doesn’t work.
What can I do?
Well, it would be easier to just have a normal
UIViewControllerwith aUIViewas root of the Nib and then put aUITableView. My answer is based on your need to have buttons on thatUIView.