使用Segue和Alertview进行按钮操作

时间:2012-05-15 07:37:52

标签: xcode4 uialertview segue uistoryboard

我有UIStoryboardSegue设置,如果存在某种情况则要执行AlertView,取消警报以停止执行Sese,然后单击OK继续执行performSegue。我唯一的问题是处理发件人ID,因为performSeguewithIdentifier需要进入alertView按钮单击方法。如何保留发件人(身份证)?

- (IBAction)drink1Button:(id)sender {


    if([drink1Units.text intValue] > 0)
    {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You Chose" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];

        [alert show];
        [alert release];
    }

}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"DrinkSegue"]) {


    // Get destination view
    DrinksListViewController *selectedDrink = [segue destinationViewController];

    // Get button tag
    NSInteger tagIndex = [(UIButton *)sender tag];

    // Set the selected button in the new view
    [selectedDrink setSelectedButton:tagIndex];
    }
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1) {
       [self performSegueWithIdentifier:@"DrinkSegue" sender:sender];
}

0 个答案:

没有答案