- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - phát hiện rò rỉ bộ nhớ Ruby/Ruby on Rails
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
开始练习swift。在 singleViewController 中,我试图制作一个 UITableView
。在 Storyboard 中,我设置了数据源和委托(delegate)。在这里我收到错误 * 'ViewController' does not conform to protocol 'UITableViewDataSource' *
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var table: UITableView!
ghi đè hàm viewDidLoad() {
siêu.viewDidLoad()
// Thực hiện bất kỳ thiết lập bổ sung nào sau khi tải chế độ xem, thường là từ một nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
func numberOfSectionsInTableView(tableView: UITableView!) -> Int
{
return 20
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
let cell:UITableViewCell=UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "mycell")
cell.textLabel.text="row#\(indexPath.row)"
cell.detailTextLabel.text="subtitle#\(indexPath.row)"
return cell
}
câu trả lời hay nhất
您应该在最后一个 之前实现所有必需的方法,但是您已经在 UIViewController 之外编写了它们。此外,您需要更改行数的函数。
建议的修改
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var table: UITableView!
ghi đè hàm viewDidLoad() {
siêu.viewDidLoad()
// Thực hiện bất kỳ thiết lập bổ sung nào sau khi tải chế độ xem, thường là từ một nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(tableView:UITableView!, numberOfRowsInSection section:Int) -> Int
{
return 20
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
let cell:UITableViewCell=UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "mycell")
cell.textLabel.text="row#\(indexPath.row)"
cell.detailTextLabel.text="subtitle#\(indexPath.row)"
return cell
}
}
关于ios - 类型 'ViewController' 不符合协议(protocol) 'UITableViewDataSource',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25581780/
我已经检查了其他几个问题,答案似乎在数据源方法的声明中。但是,我找不到我的方法声明有什么问题。 这是我的类(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”错误。我已经实现了所需的功
Tôi là một lập trình viên xuất sắc, rất giỏi!