我有三个关于单选按钮的问题,我希望用户可以回答所有不应该移动到下一个屏幕的问题,所以我已经声明了一个 BOOL isClicked 并在所有按钮都被点击时使它成为真的。
但是当任何一个按钮被选中并且它移动到下一个屏幕时它会起作用但它应该检查所有三个问题按钮所以我需要为所有按钮或其他任何事情添加不同的布尔值现在我正在这样做
-(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];
}