我正在使用按钮中的图像来制作按钮单选按钮。我可以通过更改图像来检查它,但我无法取消选中它。请帮我。我在按钮操作中使用此代码
[sender setImage:[UIImage imageNamed:@"check2.png"] forState:UIControlStateNormal];
答案 0 :(得分:0)
您将在viewController中存储按钮的状态...
BOOL checked;
-(void)viewDidLoad {
checked = YES; //Set depending on your initial state
}
-(IBACtion)pressed:(UIButton *)sender {
checked = !checked;
[sender setImage:[UIImage imageNamed:((checked) ? @"check2.png" : @"NOTCHECKEDIMAGE.png")] forState:UIControlStateNormal];
}