开发者

UIAlert View-for yes/no condition

开发者 https://www.devze.com 2023-01-05 07:17 出处:网络
my app needs alert msg and with yes button click another alert msg which decides the final a开发者_如何学Pythonction.

my app needs alert msg and with yes button click another alert msg which decides the final a开发者_如何学Pythonction. I have used - (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex this method.

Please help me.


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
}


Check this out http://www.timeister.com/2010/06/objc-show-alert-iphone/

// open a alert with an OK and cancel button
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"UIAlertView" 
        message:@"My message" delegate:self cancelButtonTitle:@"Cancel"
        otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
0

精彩评论

暂无评论...
验证码 换一张
取 消