将UIViewController更改为UITableViewController? [英] Change UIViewController to a UITableViewController?

查看:97
本文介绍了将UIViewController更改为UITableViewController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableView,我想从中重新加载数据。我知道怎么做,但是当从[self.tableView reloadData]调用它时,我得到的错误与我当前的UIViewController配置如下:

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> {

所以我的想法是将UIViewController更改为UITableViewController,如下所示:

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.'

在界面构建器中,那里没有 tableView 连接(但是有委托和dataSource)。

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

我做错了什么?

谢谢,

Coulton

Thanks,
Coulton

推荐答案

听起来好像需要将Interface Builder中控制器实例的标识(换句话说是类)设置为自定义子类。

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.

顺便说一下,IB中没有公开 UITableView tableView 属性,因为它本质上是一个sy 视图属性的nonym - 两个属性都引用相同的实例变量 _view tableView 属性只是更强类型。

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.

只是附注:按照惯例,Objective-C类名应该以大写字母开头,即 ProcessViewController ,而不是 processViewController

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

这篇关于将UIViewController更改为UITableViewController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆