Reputation: 2194
I am trying to insert a custom UITableViewController
inside a Container View
. The Container View is placed inside a cell of a static UITableView as shown in the figure below.
I simply want a method to combine static with dynamic cells in the same screen.
In the Identity Inspector
when the field Class is empty (i.e. a standard UITableViewController) it works showing an empty dynamic table inside the cell. But when I put my custom class name (that extends UITableViewController) in that field I get a NSInternalInconsistencyException
:
[UITableViewController loadView] loaded the "Enx-aT-Rum-view-zY2-9U-Z6d" nib but didn't get a UITableView.
These are the contents of MyCustomUITableViewController:
@implementation MyCustomUITableViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
@end
I have to admit that I still don't understand all the logic behind Container View, but I just want to show only one view inside (not doing any swapping or else).
Any help would be appreciated, thanks!
Upvotes: 1
Views: 3134
Reputation: 2194
After banging my head on the desk for so many hours I managed to resolve this.
I had to alloc/init the tableview of MyCustomUITableViewController. I override the loadView
method of MyCustomUITableViewController:
- (void) loadView{
self.tableView = [[UITableView alloc]init];
}
And it is good to go!
Upvotes: 1