swif tableview全选
func selctAll() {
idArr.removeAll()
for var i = 0; i<sellingArr.count; i++ {
let path: NSIndexPath = NSIndexPath(forRow: i, inSection: 0)
self.tableView.selectRowAtIndexPath(path, animated: true, scrollPosition: UITableViewScrollPosition.None)
}
}
//取消全选
func cancelSelectAll() {
for var i = 0; i < sellingArr.count; i++ {
let path: NSIndexPath = NSIndexPath.init(forItem: i, inSection: 0)
self.tableView.deselectRowAtIndexPath(path, animated: true)
}
tableView.setEditing(false, animated: true)
}
//代理中除了要实现必须实现的代理以外有些需要注意的地方
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCellWithIdentifier(BSManagerBaseCellID) as! BSManagerTableViewCell
cell.selectedBackgroundView = UIView()// 这句可以淡化选择时的颜色
return cell
}
//编辑时写法,OC中写法相对简单,可以百度需要的OC的同学
override func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
return UITableViewCellEditingStyle(rawValue: UITableViewCellEditingStyle.Delete.rawValue | UITableViewCellEditingStyle.Insert.rawValue)!
}
//选中时在这里操作
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let path: NSIndexPath = NSIndexPath.init(forItem: indexPath.row, inSection: 0)
let cell = tableView.cellForRowAtIndexPath(path) as! BSManagerTableViewCell
if cell.selected == true {//如果是选中状态的话,我在这里的操作是把选中cell的id放在了一个数组中。
idArr.append((sellingArr[indexPath.row]["id"] as? String)!)
}
}
//取消选中的cell状态
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) {
if isSelectStatus == true {//如果是选中状态的话,我在这里的操作是把选中cell的id从数组中移除。
idArr.removeAtIndex(idArr.indexOf((sellingArr[indexPath.row]["id"] as? String)!)!)
}
}
swif tableview全选的更多相关文章
- 【iOS】UITabView/UICollectionView 全选问题
UITabView/UICollectionView 全选问题 SkySeraph July. 30th 2016 Email:skyseraph00@163.com 更多精彩请直接访问SkySera ...
- UITableViewCell 多选和全选(checkBoxCell)
思路1 一.全选 1.创建可变数组,存储所有未选中状态(NO)的布尔值按钮,点击时改变其状态,并传入按钮的状态. 二.多选 1.创建Cell时,从数组中取出相应的值,传给cell,如果为YES,否则为 ...
- UITableView多选全选
自定义cell和取到相应的cell就行了 TableViewCell.h #import <UIKit/UIKit.h> @interface TableViewCell : UITabl ...
- IOS开发学习笔记029-反选、全选、删除按钮的实现
还是在上一个程序的基础上进行修改 1.反选按钮 2.全选按钮 3.删除按钮 4.其他代码优化 1.反选按钮 反选的过程就是将_deleteShops数组中得数据清空,然后将Shops中数组添加到_de ...
- Jquery的点击事件,三句代码完成全选事件
先来看一下Js和Jquery的点击事件 举两个简单的例子 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&q ...
- 表格与ckeckbox的全选与单选
先看看下面的效果: 用户点击头的checkbox时,所有表格数据行的checkbox全选或反选. 当数据行某一行没有选中时,头checkbox去选.当所有数据行的checkbox全选时,头的check ...
- jQuery全选、全不选、反选
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script sr ...
- java script第一篇(按钮全选的实现)
今天刚学了java script,记录下学习新知识的点滴.以下是操作步骤.鉴于我是初级者,如有错误,恳请读者指正.万分谢谢. 1.新建一个文档(用NotePad软件,为了使得在浏览器中打开不是乱码,在 ...
- js动态获取子复选项并设计全选及提交
在做项目的时候,会遇到根据父选项,动态的获取子选项,并列出多个复选框,提交时,把选中的合并成一个字符提交后台 本章将讲述如何通过js控制实现该操作: 1:设计父类别为radio,为每一个radio都加 ...
随机推荐
- [LintCode] Scramble String 爬行字符串
Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...
- CG资源网 - Maya教程
Maya中mentalray灯光渲染终极训练视频教程 http://www.cgtsj.com/cg/f/vx3627/index.html Maya无人机建模制作训练视频教程第一季 http://w ...
- curl测试网页响应时间
连接时间: curl -s -o /dev/null -w "%{time_connect}\n" http://www.joinpay.com 传输时间: curl -s -o ...
- c#面向对象基础 封装、继承
一.封装 这是一种隐藏的特性.可以用一个公式来展示类的封装特性: 封装的类=数据 + 对此数据进行的操作(即算法) 通俗的说,封装就是:包起外界不必要知道的东西,只向外界展露可供展示的东西. 在面 ...
- CacheManagerUtils.java
package com.vcredit.framework.utils; import net.sf.ehcache.Cache;import net.sf.ehcache.CacheManager; ...
- Linux下一些有用的指令
1. 安装源代码包用到的configure 这用来定位安装位置. 用法: ./configure -prefix=<安装目录>, 前提是文件中有configure执行文件.
- Python一般错误
1. IndentationError: unindent does not match any outer indentation level 格式对齐的问题.Python对空格和Tab有严格区别
- php课程---文件操作及文件上传的代码总结
php里面文件包含目录和文件两种 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "h ...
- [转]如何将SQL Server表驻留内存和检测
注意这个功能在SQL2005后已经废弃,因为SQL2005会自动管理哪些表常驻内存. 将SQL Server数据表驻留内存是SQL Server提供的一项功能,在一般小型系统的开发过程中估计很少会涉及 ...
- php mysql_num_rows() 与 mysql_affected_rows()
mysql_num_rows(data) 函数返回结果集中行的数目. data 结果集.该结果集从 mysql_query() 的调用中得到. 此命令仅对 SELECT 语句有效.要取得被 INSER ...