[英]Assigning UITableView delegate and dataSource to super in Swift
[英]Swift UITableView : Datasource assigning Issue
这是一个简单的UITableView
代码,可以在操场上正常工作 :
import UIKit
class MyDataSuorce : NSObject, UITableViewDataSource {
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!
{
let cell = UITableViewCell(style: .Value2, reuseIdentifier: nil)
cell.textLabel.text = "Row #\(indexPath.row)"
return cell;
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
{
return 4
}
}
let list = UITableView(frame:CGRectMake(0,0,300,300), style: .Plain)
let d = MyDataSuorce()
list.dataSource = d
list.reloadData()
但是,当我第一次尝试此代码时, 它不起作用,只是显示一个空的UITableView
:
let list = UITableView(frame:CGRectMake(0,0,300,300), style: .Plain)
list.dataSource = MyDataSuorce()
list.reloadData()
第二个代码有什么问题?
编辑:
这是list.dataSource = MyDataSuorce()
的控制台输出:
游乐场执行失败:错误:错误:无法查找符号:_memmove
也许我解决了“ 为什么? ” ...
我认为,这是关于快速可变寿命的 。 (正确?)
在第二个代码中,我只是忘记了返回的对象(通过MyDataSource()
)将在该行代码中存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.