- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
如果我使用自定义单元格 BaseCell
,则无法导入 UITableViewDataSource。仅适用于 UITableViewCell
尽管 BaseCell
来自类型 UITableViewCell
import UIKit
class XptoViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var table: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(_ tableView:UITableView, numberOfRowsInSection section:Int) -> Int {
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> BaseCell {
let cell = BaseCell()
return cell
}
最佳答案
尝试相反的方法:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = BaseCell()
return cell
}
但你可能想使用类似的东西:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("BaseCell") as? BaseCell
return cell!
}
关于ios - 无法将 UITableViewDataSource 与自定义单元格一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43326701/
我已经检查了其他几个问题,答案似乎在数据源方法的声明中。但是,我找不到我的方法声明有什么问题。 这是我的类(class): import UIKit class GuestControl: UITab
到目前为止,我很喜欢 MonoTouch,但是一旦您通过了几个初学者类(class),就会发现缺少文档和示例。 我正在努力解决在 MonoTouch 中填充简单 UITableView 的简单概念。我
在我们的应用程序中,我们有几个 UITableView,它们具有网络支持的数据源,实际填充这些数据源可能需要一些时间。以下是通常发生的情况: 用户触发 View 。 在 viewDidLoad 中,创
我有一个 UITableView,它应该呈现分成部分 的条目。数据需要一些时间来处理,因此它是这样完成的: @interface AsyncTable() NSMutableArray* _alp
数据源方法没有被触发我的 tableView 仍然是空的。使用断点,我可以看到数据源从未执行过我不明白为什么以及如何 import UIKit class SearchResultsViewContr
class EmployeeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var emp
我有一个 NSArray 从服务器获取的歌曲。那是我的原始数据源。该数组包含以 NSDictionary 和 NSArray 作为后端的自定义对象。 我想知道使用 NSDictionary 实现格式化
尝试将我的表的值分配给 self 时出现以下错误。 Cannot assign a value of type 'ActivityViewController' to a value of type
如何在 Swift 中定义协议(protocol):( @protocol Protocol - (Class)generateObject; @end 编辑:如果我想在 OC 中定义一个函数,如下
我在我的一个 UITableViews 中遇到索引越界异常,我认为可能是一些多线程问题。这是我认为正在发生的事情: 我有一个 UITableView,它的数据源是一个普通的 NSMutableArra
我在连接到 TodayViewController 的 ViewController 中使用 UITableView。我想使用我的 Parse 数据库中的数据加载到 TableView 中。 这是我的
我从 Xcode 模板创建了一个新的主从应用程序 我发现主界面(在本例中为 BirdMasterViewController)继承自 UITableViewController,和 UITableVi
我写代码有困难,协议(protocol)出错,我用的是xcode 7.3.1 //2 Method dari protokol UITableViewDataSource->method 1. fun
目前,我在我的应用程序中设置了以下内容: 例如,我有一个游戏列表,其中的游戏有不同的状态,我希望某个状态位于某个部分等。 因为我有 3 种不同的状态,所以我将使用 NSDictionary,其中 St
由于 UITableView 在 UIViewController 中,我创建了一个符合 UITableViewDataSource 协议(protocol)的类,并将其附加到 UIViewContr
我的项目中有 4 个文件: myTableViewController.swift myTableViewDataSource.swift myCustomCell.swift 我的自定义单元格.xi
我在 Xcode 8 beta 中编写了 tableView 的代码,然后尝试在实际的 Xcode 7 中执行它。除了 UITableViewDataSource 问题外,我下面的代码看起来是正确的。
问题:如何通过扩展编写 UITableViewDataSource 的默认实现? Swift支持协议(protocol)扩展中的默认实现,UITableViewDataSource是一个协议(prot
我设置了 tableview 数据源,但它无法识别他的错误类型“ViewController”不符合协议(protocol)“UITableViewDataSource” import UIKit c
因此,我在 Xcode 中收到“Type ViewController does not conform to protocol UITableViewDataSource”错误。我已经实现了所需的功
我是一名优秀的程序员,十分优秀!