【发布时间】:2015-06-15 18:24:39
【问题描述】:
谢谢大家。但我需要告诉你全部情况。我有一个集合视图单元格。在里面我添加了复选框。并且“全选”按钮位于集合视图之外。因此,如果我单击“全选”按钮,它应该选中集合视图单元格内的所有复选框。我在集合 viewcell 中添加了一个 customuibutton。 CustomUIButton *checkboxButton=[CustomUIButton buttonWithType:UIButtonTypeRoundedRect]; [checkboxButton setTaggy:indexPath.row]; //[checkboxButton setTag:CHECKBOX_BUTON_ON_CELL+indexPath.row+indexPath.section]; // [checkboxButton setCollectionIdentifier:collectionView.tag]; [复选框按钮添加目标:自我 动作:@selector(checkBoxAction:) forControlEvents:UIControlEventTouchUpInside]; checkboxButton.frame = CGRectMake(168.0, 3.0, 20.0, 20.0); [checkboxButton setSection:indexPath.section];
[checkboxButton setHighlighted:NO];
if (clsPartcipant.isSmallChanged)
{
[checkboxButton setBackgroundImage:[UIImage imageNamed:@"selected1.png"] forState:UIControlStateNormal];
}
else
{
[checkboxButton setBackgroundImage:[UIImage imageNamed:@"unselected.png"] forState:UIControlStateNormal];
}
[checkboxButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
[cell.contentView addSubview:checkboxButton];
});
return cell;
我调用了一个类似 checkBoxAction 的函数。 -(void)checkBoxAction:(id)sender{ CustomUIButton *button=sender; BOOL 标志 = 否;
if (button.selected)
{
[button setSelected:NO];
[button setBackgroundImage:[UIImage imageNamed:@"unselected.png"] forState:UIControlStateNormal];
flag=NO;
}
else
{
[button setSelected:YES];
[button setBackgroundImage:[UIImage imageNamed:@"selected1.png"] forState:UIControlStateNormal];
flag=YES;
}
if (button.collectionIdentifier == ClsRmPrctPresntCollectionView)
{
[self ModifyDataArray:button.taggy flag:flag identifier:ClsRmPrctPresntCollectionView change:@"SmallButton" toDate:nil section:button.section];
[self modifyCollectionArray:PRESENT processingData:self.presentDataArray identifier:ClsRmPrctPresntCollectionView index:button.taggy section:button.section];
}
} 现在我无法弄清楚我需要在 selectAll 按钮操作中添加什么。请在这方面帮助我
【问题讨论】:
-
我的回答对你来说几乎是复制粘贴。但请务必阅读其评论。如果它适合你,则标记为正确