uitableview - 两个 tableView 函数相互冲突

标签 uitableview swift

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {              
            return self.arrayLength
        }

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
        return cell
}

它会打印下一个错误:“'tableView' 的前一个定义在这里”(定义与前一个值冲突)。为什么它们会相互冲突?

最佳答案

所以我们终于找到了这个问题的答案。首先是the whole code for the Problem . (JSON 的东西来自 SwiftyJson )

这里的问题是 Orkhan 忘记在类定义中使用 UITableViewDataSource 协议(protocol)并且没有将 tableView.dataSource na delegate 设置到他自己的类中。这样做之后问题就解决了。

关于uitableview - 两个 tableView 函数相互冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29487815/

相关文章:

ios - 插入另一个 View Controller 后,searchBar 不会隐藏

ios - 将 UITableViewCell 类中的选择器添加到 UITableViewController 类

ios - 在 iPad 上 : UITableView's separator between header and cells

uitableview - 快速隐藏Tableview的静态单元格

ios - 一些用户没有出现在搜索解析 iOS 中

swift - 在 Swift 中动态获取 AnyObject 的类型

swift - 如何确定 Swift 代码是否在 XCode Playground 中运行

ios - 如何从导航堆栈中删除 ViewController 并且没有返回它的选项-Swift

ios - 使用 Swift 解析 'Quick Start' - 'PFObject' 没有名为 'subscript' 的成员

iOS- Swift 中的 (`FirebaseApp.configure()`)在使用 Firebase 数据库之前。