Change UIViewController to a UITableViewController

2019-05-29 02:42发布

I have a UITableView that i want to reload the data from. I know how to do that, but when calling it from [self.tableView reloadData], I get errors with my current UIViewController configuration like this:

@interface processViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {

So my thought would be to change the UIViewController to a UITableViewController like this:

@interface processViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource> {

// or this:

@interface processViewController : UITableViewController {

However, when trying to load the view i get this error:

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "processView" nib but didn't get a UITableView.'

When in interface builder, there is no tableView connection there (but there are delegate and dataSource).

What am I doing wrong?

Thanks,
Coulton

1条回答
叼着烟拽天下
2楼-- · 2019-05-29 03:34

It sounds as though you need to set the identity (in other words the class) of the controller instance in Interface Builder to your custom subclass.

By the way, the tableView property of UITableView isn't ever exposed in IB, because it's essentially a synonym for the view property -- the two properties both refer to the same instance variable, _view. The tableView property simply is more strongly typed.

Just a side note: by convention, Objective-C class names should begin with a capital letter, i.e., ProcessViewController, not processViewController.

查看更多
登录 后发表回答