overriding loadView in a UITableViewController subclass
Turns out I need to set the dataSource and delegate of my tableView as a part of loading. So when I do this, everything works fine:
- (void) loadView {
MyTableViewSubclass* tv = [[[MyTableViewSubclass alloc]initWithFrame: CGRectZero style: UITableViewStylePlain]autorelease];
tv.dataSource = self;
tv.delegate = self;
self.view = tv;
self.tableView = tv;
}
William's answer help me over the last hurdle too.
To add a swift example, the pattern I commonly use is:
class SomeTableViewController: UITableViewController {
private var childView: SomeTableView! { return tableView as! SomeTableView }
override func loadView() {
tableView = SomeTableView(frame: UIScreen.mainScreen().bounds, style: .Plain)
tableView.delegate = self
tableView.dataSource = self
view = tableView
}
}
You are then free to refer to the customised view as childView in other places in the ViewController.