大佬教程收集整理的这篇文章主要介绍了swift__UITableView 的数据源方法 和 代理方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
//MARK:- UITableView 的数据源方法 和 代理方法
// 返回行数
func tableView(tableView: UITableView,numberOfRowsInSection section: Int) -> Int
return keyPointArray.count
}
func tableView(tableView: UITableView,cellForRowATindexPath indexPath: NSIndexPath) -> UITableViewCell
// cell的标识符,为了重复利用一个cell显示多行数据(复用)
let cellID = "keyPointCell"
@H_618_95@
let myCell:UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default,reusEIDentifier: cellID)
myCell.textLabel?.text = keyPointArray[indexPath.row]
myCell.accessoryType = UITableViewCellAccessoryType.checkmark
return myCell
}
// 是否允许打开编辑状态
func tableView(tableView: UITableView,commitEdiTingStyle ediTingStyle: UITableViewCellEdiTingStyle,forRowATindexPath indexPath: NSIndexPath)
}
// 删除某行cell
// func tableView(tableView: UITableView,commitEdiTingStyle ediTingStyle: UITableViewCellEdiTingStyle,forRowATindexPath indexPath: NSIndexPath)
// {
//
// }
// 允许滑动删除
func tableView(tableView: UITableView,ediTingStyleForRowATindexPath indexPath: NSIndexPath) -> UITableViewCellEdiTingStyle {
return (UITableViewCellEdiTingStyle.delete)
}
// 允许移动某行(排序)
func tableView(tableView: UITableView,canMoveRowATindexPath indexPath: NSIndexPath) -> Bool {
return true
}
// 实现排序
func tableView(tableView: UITableView,moveRowATindexPath sourceIndexPath: NSIndexPath,toIndexPath desTinationIndexPath: NSIndexPath) {
}
// 点击某行
func tableView(tableView: UITableView,didSELEctRowATindexPath indexPath: NSIndexPath) {
print("点击了第\(indexPath.row)行")
}
以上是大佬教程为你收集整理的swift__UITableView 的数据源方法 和 代理方法全部内容,希望文章能够帮你解决swift__UITableView 的数据源方法 和 代理方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。