购物车界面,不同section,点击增减物品,确定取消选中的逻辑判断
1、首先在自定义的cell中,创建两个代理方法
@protocol shopCartDelegate <NSObject>
-(void)shopCartDelegate:(ShopCartCell *)cell WithBtn:(UIButton *)btn;
-(void)shopCartDelegateNum:(ShopCartCell *)cell WithBtn:(UIButton *)btn;
@end
@interface ShopCartCell : UITableViewCell
@property(nonatomic,assign)id<shopCartDelegate>delegate;
@end
2、在viewcontroller中实现这两个代理方法
shopCell.delegate = self;//遵循代理
方法实现
(1)选中和取消的代理方法
-(void)shopCartDelegate:(ShopCartCell *)cell WithBtn:(UIButton *)btn
{
NSIndexPath *indexPath =[self.tableView indexPathForCell:cell];
int couss=0 ;
NSArray *array =self.array[indexPath.section];
for (int i =0; i<array.count; i++) {
ShopModel *model =array[i];
if (i==indexPath.row) {
if (btn.selected) {
model.isSelected = @"true";
}else{
model.isSelected = @"false";
}
}
if ([model.isSelected isEqualToString:@"true"]) {
couss++;
}
}
//判断section内的cell是否都被选中
if (couss == array.count) {
self.isonOff = NO;
}else{
self.isonOff = YES;
}
[self.tableView reloadData];
}
(2)增加减少
-(void)shopCartDelegateNum:(ShopCartCell *)cell WithBtn:(UIButton *)btn
{
NSIndexPath *indexPath =[self.tableView indexPathForCell:cell];
NSArray *array =self.array[indexPath.section];
for (int i =0; i<array.count; i++) {
ShopModel *model =array[i];
if (i==indexPath.row) {
if (btn.tag == 2000) {
model.num =[NSString stringWithFormat:@"%d",model.num.intValue+1];
}else{
if (model.num.intValue == 1) {
}else{
model.num =[NSString stringWithFormat:@"%d",model.num.intValue-1];
}
}
}
}
[self.tableView reloadData];
}
购物车界面,不同section,点击增减物品,确定取消选中的逻辑判断的更多相关文章
- JAVA面向对象编程之购物车界面的设计与功能的实现
1.小组成员及分工 小组成员 负责工作 兰泽祥 负责总体界面.Git代码库 吴修恩 负责MVC模式.类名包名的规范化 2.Git 仓库地址 仓库地址:https://gitee.com/lanzexi ...
- ContactDetail 和 ContactEditor 界面头像响应点击过程
1,联系人详情界面 ContactDetailFragment中处理,ViewAdapter装载数据显示头像 private final class ViewAdapter extends BaseA ...
- 在用easyui中做CRUD功能时,当删除一行或多行数据后再点击修改会提示你选中了多行,如何解决这个bug了?
在用easyui中做CRUD功能时,当删除一行或多行数据后再点击修改会提示你选中了多行,如何解决这个bug了? 在删除成功后,加上这句话就可以了:$("#dg").datagrid ...
- jquery 复选框全选/全不选切换 普通DOM元素点击选中/取消选中切换
1.要选中的复选框设置统一的name 用prop() prop() 方法设置或返回被选元素的属性和值. $("#selectAll").click(function(){ $(&q ...
- input选中 和 select点击下拉选择获取选中选项的值
1.input选中$('#checkBox').find('input').each(function(i){ if($(this).prop('checked')){//获取是否选中 并判断 $(t ...
- Android Splash界面支持用户点击 直接进入主界面
转载请注明出处:http://blog.csdn.net/lmj623565791/article/details/23613403 现在大部分APP都有Splash界面,下面列一下Splash页面的 ...
- unigui ios微信界面错位和点击失灵问题
IOS微信下会出现二个严重问题: 1.输入框失去焦点导致控件错位,造成无点正常点击. 此问题是微信自带浏览器,一直遗留问题, 尝试了多种方法始终无解.因此要用来开发公众号的一定要注意. 2.界面下移 ...
- linux系统(CentOS7)虚拟机上安装oracle 11g,解决oracle图形界面卡住无法点击next问题
https://www.cnblogs.com/nichoc/p/6416475.html
- 2-微信小程序开发(开发界面说明,按钮点击切换显示内容)
说一个功能,大家在用微信实现控制设备的时候,是不是都在为绑定设备发愁. 我看了很多厂家的微信控制,大部分都只是可以用微信给设备配网,但是没有做用微信绑定的. 一般做绑定都是用设备的MAC地址. 这里我 ...
随机推荐
- 图像滤波:Gabor滤波
- LeetCode 342. Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Giv ...
- 4.Single Number && Single Number (II)
Single Number: 1. Given an array of integers, every element appears twice except for one. Find that ...
- Chap6: question38 - 42
38. 数字 k 在有序数组中出现的次数 二分查找:找出第一个 k 和最后一个 k . #include <iostream> using namespace std; int getFi ...
- PHP文件读写操作之文件写入代码
在PHP网站开发中,存储数据通常有两种方式,一种以文本文件方式存储,比如txt文件,一种是以数据库方式存储,比如Mysql,相对于数据库存储,文件存储并没有什么优势,但是文件读写操作在基本的PHP开发 ...
- 类似新浪 腾讯微博字数统计 控制js(区分中英文 符号)
<script> ; function Q(s) { return document.getElementById(s); } function checkWord(c) { len = ...
- Linux学习笔记——使用指定的用户权限执行程序——sudo
sudo可以用来以其他用户身份执行命令,sudo命令可以针对单个命令授予临时权限.sudo仅在需要时授予用户权限,减少了用户因为错误执行命令损坏系统的可能性. 1:sudo的帮助信息如下: ...
- 一个CString的实现 拷贝构造函数的应用
class CString { public: CString (char* s); CString(); ~CString(); private: char *str; int len; stati ...
- Reprot中的五个Trigger说明
Report Trigger 1.1 Which report trigger to use As a general rule, any processing that will affect th ...
- mysql修改列名字段类型
mysql> alter table lesson change title title varchar(100) charset utf8;