iPhone:TabView + TableView

标签 iphone uitableview uitabbarcontroller datasource delegates

我认为我错过了一些简单的东西,但我无法弄清楚它到底是什么。

我正在尝试使用 UITabViewController 设置一个应用程序,其中一个选项卡将具有 UITableView 和 UISearchBar(但没有导航 Controller )。我使用界面生成器中的所有选项卡设置了 UITabViewController,并且 View 位于它们自己的 xib 文件中。带有 UITableView 的选项卡的 xib 文件设置并连接如下。

浏览器中的内容: 文件的所有者(Class 是我的自定义类,它是 UITableViewController 的子级) View -> View

View (class UIView, reference view -> File's owner) contains:
      UITableView (if i try and set references to the data source / delegate, the app breaks)
      UISearchBar (unconfigured at the moment)

此设置显示所有项目并且不会锁定,但当我尝试使用 UITableView 加载选项卡时,我无法分配数据源而不崩溃。我应该怎么做才能将数据放入此表中,无论是在 IB 中还是在代码中?我的想法如下:

  1. 实现自定义 UITableView 类,连接到 IB 中的 TableView 或 Xcode 中的自定义 tableviewcontroller。
  2. 将头或笔记本电脑靠在墙上,直至其正常工作。

更新: 这是当我连接 Tableview 的数据源并委托(delegate)给文件所有者(谁的类是我的自定义 tableviewcontroller)时模拟器推送到控制台的错误。

2/14/09 6:59:12 PM TabBarWillbeRight[33172] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x523760

最佳答案

我遇到了类似的问题,并带有相同的错误消息。简单的解决方案是在 IB 中单击 TabBarController 中的 View (灰色矩形,上面写着“ View 加载自..”),并将元素的类更改为我的 TableViewController 的类名。

关于iPhone:TabView + TableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/550026/

相关文章:

iphone - 应用程序中任何位置的持久 View

ios - 如何将 AdBannerView 添加到 UITabViewController?

ios - 如何在 iOS 中实现 SSL Pinning?

iphone - 代码签名错误 : code signing is required for product type 'Application' in SDK 'iOS 5.1'

iphone - UITableView 一次添加带有动画的行,但延迟显着

iphone - 使用字符串在 unichar 中显示 emogi 图标

Swift - 为一个表中的不同单元格设置不同的行高

ios - 如何设置 UITableView 右侧 sectionIndex 的字体大小?

ios - 在 UITableview 的单元格中输入数据

exception - MonoTouch 的 UIViewControllerHierarchy 不一致异常