nick shmick
nick shmick

Reputation: 925

Connecting UITableView to UIView error

sorry if the question is a beginners one its because I am a beginner.

I have a nib file that called HistoryLogTableViewController. in this nib file I have a UIView and a UITableView, the UIView is the parent of the UITableView.

HistoryLogTableViewController screenshot:

enter image description here

This nib file have a view controller called HistoryLogTableViewController that have a table view property in the .h file that is connected to the files owner, it looks like this:

enter image description here

and this is the property in the .h file:

@property (strong, nonatomic) IBOutlet UITableView *tableView;

now from what I knew if I run the app now it should work...just load an empty table view...but when I click on the button that opens this table view the app crashes and I get this error:

reason: '-[UITableViewController loadView] loaded the "HistoryLogTableViewController" nib but didn't get a UITableView.'

Upvotes: 3

Views: 79

Answers (1)

Warren Burton
Warren Burton

Reputation: 17382

Im guessing your class looks like this

@interface HistoryLogTableViewController : UITableViewController

A UITableViewController MUST have a UITableView as the root view of the controller not a UIView.

change it to this

@interface HistoryLogTableViewController : UIViewController

and it should stop crashing.

Upvotes: 2

Related Questions