0

I have an iphone app i want that befor moving to next screen it should click on any of the 4 or five button i have and if user does not click on any button then it may not move to next screen

Firs two button from which user must click any one to move to next otherwise not

-(IBAction)locationOneButtonAction{

    UIImage *buttonImage = [UIImage imageNamed:@"radiogreen.png"];  
    UIImage *buttonImageOne=[UIImage imageNamed:@"radiowhite.png"];

    [locationOneButton setImage:buttonImage forState:UIControlStateNormal];
    [locationOneButton setImage:buttonImage forState:UIControlStateNormal];

    [locationThreeButton  setImage:buttonImageOne forState:UIControlStateNormal];
    [locationTwoButton  setImage:buttonImageOne forState:UIControlStateNormal];

    [locationFourButton  setImage:buttonImageOne forState:UIControlStateNormal];
    [locationFiveButton  setImage:buttonImageOne forState:UIControlStateNormal];
    [locationSixButton  setImage:buttonImageOne forState:UIControlStateNormal];

    resturantLocation=@"Common Man - Bedford, MA";
}


-(IBAction)locationTwoButtonAction{

    UIImage *buttonImage = [UIImage imageNamed:@"radiogreen.png"];
    UIImage *buttonImageOne=[UIImage imageNamed:@"radiowhite.png"];

    [locationOneButton setImage:buttonImageOne forState:UIControlStateNormal];
    [locationThreeButton  setImage:buttonImageOne forState:UIControlStateNormal];
    [locationTwoButton  setImage:buttonImage forState:UIControlStateNormal];
    [locationFourButton  setImage:buttonImageOne forState:UIControlStateNormal];

    [locationFiveButton  setImage:buttonImageOne forState:UIControlStateNormal];
    [locationSixButton  setImage:buttonImageOne forState:UIControlStateNormal];

    resturantLocation=@"Common Man - Arlingtion, NY";
}

Next Button Move to the next Screen

-(IBAction)nextButton{

    FoodViewController*targetController=[[FoodViewController alloc]init];
    targetController.resturantLocation=resturantLocation;

    [self.navigationController pushViewController:targetController animated:YES];
}
4

2 回答 2

1

最简单的方法是在 .h 文件中获取一个标志。

BOOL _flag;

viewWillAppear将其设置为_flag = NO;

在进入下一个屏幕之前必须单击的每个按钮的操作上,将其设置为YES

-(IBAction)locationOneButtonAction{
    // your stuff
    _flag = YES;
}
-(IBAction)locationTwoButtonAction{
    // your stuff
    _flag = YES;
}

在你的下一个按钮点击使用它像

-(IBAction)nextButton{

    if(_flag) {
        FoodViewController*targetController=[[FoodViewController alloc]init];
        targetController.resturantLocation=resturantLocation;
        [self.navigationController pushViewController:targetController animated:YES];
    }
}

希望这会有所帮助:) 如果您正在寻找其他东西,请告诉我

于 2012-07-02T04:56:20.240 回答
0

您可以使用 bool 标志来识别是否单击了任何按钮。如果单击了任何按钮,只需将该 bool 标志设为 true,否则将其初始化为 false,当用户单击下一步时,只需检查该 bool 标志是否为 true 或false。如果为 false,则不允许用户继续。

于 2012-07-02T04:56:11.953 回答