UIAlert View-for yes/no condition

前端 未结 2 749
小鲜肉
小鲜肉 2021-01-29 12:06

my app needs alert msg and with yes button click another alert msg which decides the final action. I have used - (void)alertView:(UIAlertView *)alertView didDismissWithB

2条回答
  •  暖寄归人
    2021-01-29 12:48

    Do what @Adrian Pirvulescu said but before showing the alert do alert.tag = 1; and then when - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex is called do:

    if (alertView.tag == 1) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"2nd Alert" 
        message:@"My message" delegate:self cancelButtonTitle:@"Cancel"
        otherButtonTitles:@"OK", nil];
        alert.tag = 2;
        [alert show];
        [alert release];
    }
    else if (alertView.tag == 2) {
        [self CallSomeMethod];
    }
    else {
        //do what ever you want here
    }
    

提交回复
热议问题