我有 UIStoryboardSegue 设置,如果存在特定条件,想执行 AlertView,取消警报以停止 performSegue 并确定继续 performSegue。我唯一遇到的问题是处理发件人 ID,因为 performSeguewithIdentifier 需要进入 alertView 按钮单击方法。我如何保留发件人(ID)?
- (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];
}