答案 0 :(得分:1)
实现复选框的最佳方法是,您可以使用按钮并切换图像.UIButton是UIController的子类,它具有selected属性。您可以使用此属性切换复选框的开/关行为
答案 1 :(得分:0)
在委托cellForRowAtIndexpath
中myButton.tag = indexPath.row
[cell.myButton addTarget:self action:@selector(shippingBtnAction:) forControlEvents:UIControlEventTouchUpInside];
- (void)shippingBtnAction:(id)sender
{
UIButton* btn = (UIButton*)sender;
btn.selected = ! btn.selected;
if (btn.isSelected)
{
_isDefaultShipping = 1;
[self.shippingBtn setImage:[UIImage imageNamed:@"check"] forState:UIControlStateNormal];
}
else
{
_isDefaultShipping = 0;
[self.shippingBtn setImage:[UIImage imageNamed:@"uncheck"] forState:UIControlStateNormal];
}
}