I have three question with radio button i want that user may give answer of all theree withu that it should not move to next screen so i have declared a BOOL isClicked
and make it true when all the buttons are clicked.
but it works when any of the buton is selected and it moves to next screen but it should check all three question button so i need to add differen bools for all the button or any thing else now i am doing like this
-(IBAction)button1Action{
UIImage *img = [UIImage imageNamed:@"selected.png"];
UIImage *img1=[UIImage imageNamed:@"unselected.png"];
[button1 setImage:img forState:UIControlStateNormal];
[button2 setImage:img1 forState:UIControlStateNormal];
[button3 setImage:img1 forState:UIControlStateNormal];
option1=@"Less than 2 hours";
isClicked = YES;
}
-(IBAction)button2Action{
UIImage *img = [UIImage imageNamed:@"selected.png"];
UIImage *img1=[UIImage imageNamed:@"unselected.png"];
[button1 setImage:img1 forState:UIControlStateNormal];
[button2 setImage:img forState:UIControlStateNormal];
[button3 setImage:img1 forState:UIControlStateNormal];
option2=@"2-5 hours";
isClicked = YES;
}
-(IBAction)button3Action{
UIImage *img = [UIImage imageNamed:@"selected.png"];
UIImage *img1=[UIImage imageNamed:@"unselected.png"];
[button1 setImage:img1 forState:UIControlStateNormal];
[button2 setImage:img1 forState:UIControlStateNormal];
[button3 setImage:img forState:UIControlStateNormal];
option3=@"More than 5 hours";
isClicked = YES;
}
if (isClicked) {
[self save_Local];
SecondViewController*targetController=[[SecondViewController alloc]init];
targetController.responseOne=responseOne;
targetController.responseTwo=responseTwo;
targetController.responseThree=responseThree;
targetController.responseFour=responseFour;
targetController.teritory=teritory;
[self.navigationController pushViewController:targetController animated:YES];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please provide all responses before proceeding to the next screen" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
in this scenario you may add three different boolean values or instead you may check this by adding a counter. Increment counter when you get answer. and then you can replace your current if statement by
if(noOfclicks > MIN_ANSWERS_REQUIRED)where noOfClicks will be your counter and MIN_ANSWERS_REQUIRED will be 3 in your case.Or
As you said these are answers, so you must be assigning value for it in some variable. You can assign this variable a default value which is not from the answers. Then when user clicks for navigating to next screen, check if all answers have different value than default value.