Reputation: 2736
I have a UIViewController with a UITableView dropped onto it in IB. It builds fine but when I run it it crashes with the error:
[UITableViewController loadView] loaded the "2-view-3" nib but didn't get a UITableView
I am using Storyboards. My view is a UIViewController not a UITableViewController but somewhere it seems to expect that it is loading a UITableViewController. In IB I set the class for the UIViewController to be my custom UIViewController class which is of type UIViewController.
Code I am trying to make work in my project is here: https://github.com/daria-kopaliani/DAContextMenuTableViewController
But it uses a UITableViewController. My project uses a UIViewController with a UITableView in it. The IB hierarchy for the demo project is as below:
But I have mine as follows:
The top of my .h of my custom UIViewController looks as follows:
Not sure if I can use the above project with anything other than a UITableViewController but that is what I am trying to do.
UPDATE:
(void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refresh) name:@"refreshTable" object:nil];
[NSFetchedResultsController deleteCacheWithName:nil];
[self initializeDateFormatter];
[self initializeTimeFormatter];
if (self.managedObjectContext == nil) {
self.managedObjectContext = [[MVCoreDataController sharedInstance] newManagedObjectContext];
}
self.tblList.delegate = self;
self.fetchedResultsController.delegate = self;
self.tblList.dataSource = self;
self.myNavBar.delegate = self;
// Do any additional setup after loading the view, typically from a nib.
}
UPDATE 2 (adding interface for MVContextMenuTableViewController):
#import <UIKit/UIKit.h>
#import "MVContextMenuCell.h"
#import "MVOverlayView.h"
@interface MVContextMenuTableViewController : UITableViewController <MVContextMenuCellDelegate, MVOverlayViewDelegate, UITableViewDelegate>
@property (readonly, strong, nonatomic) MVContextMenuCell *cellDisplayingMenuOptions;
@property (assign, nonatomic) BOOL shouldDisableUserInteractionWhileEditing;
- (void)hideMenuOptionsAnimated:(BOOL)animated;
@end
What does this error mean and how can I track it down?
Upvotes: 0
Views: 760
Reputation: 31016
You say you have a UIViewController
but in reality a MVViewController
is a type of UITableViewController
through two levels of inheritance.
Assuming you've made the class of mainVC
in your storyboard to be a MVViewController
, then its need to have a table view as its primary view is legitimate.
It seems like you need to change @interface MVContextMenuTableViewController : UITableViewController...
into @interface MVContextMenuTableViewController : UIViewController...
.
Upvotes: 1