Swift   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了swift__UITableView 的数据源方法 和 代理方法大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

//MARK:- UITableView 的数据源方法 和 代理方法          // 返回行数     func tableView(tableView: UITableView, numberOfRowsInSection section: int) -> Int     {              return keyPointArray.count     }          /

//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,请注明来意。