I have taken two custom buttons and one method, to set their check and uncheck
In viewdidload() i have written like this..
[checkbox_01 setImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];
[checkbox_02 setImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];
isChecked_01 = NO; //declared as boolean to change check and uncheck for button one
isChecked_02 = NO; //declared as boolean to change check and uncheck for button two
And in method
-(IBAction)checkboxOnClick:(UIButton *)sender {
if (sender.tag == 1) {
if (isChecked_01 == NO) {
[checkbox_01 setImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];
isChecked_01 = YES;
}
else
{
[checkbox_01 setImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];
isChecked_01 = NO;
}
}
if (sender.tag == 2) {
if (isChecked_02 == NO) {
[checkbox_02 setImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];
isChecked_02 = YES;
}
else
{
[checkbox_02 setImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];
isChecked_02 = NO;
}
}
}
is there any other way to create check boxes in ios..? i have taken each checkbox with one isChecked boolean value for it.. is there posibilities to use only one boolean for entire check list.....
Aucun commentaire:
Enregistrer un commentaire