将UIViewController更改为UITableViewController?

编程入门 行业动态 更新时间:2024-10-13 12:24:04
本文介绍了将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?

本文发布于:2023-10-27 10:38:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1533124.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:UIViewController   UITableViewController

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!