tags:

views:

47

answers:

2

Hi,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 didDismissWithButtonIndex:(NSInteger)buttonIndex this method.

Please help me.

A: 

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];
Adrian Pirvulescu
Thank Adrian.I have used this,but after ok i want another alert msg and if that is ok then i have to perform my action.Please help me.
1988
You just have to listen for *Ok delegate* result and then show a new alert. :)
Adrian Pirvulescu
Thanks Adrian Pirvulescu,but how to listen for Ok delegate result?Help me with the code please.Thanks
1988
A: 

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
}
jamone
Thanks,it is working.But when alert.tag =2 i want to call a method.Where should i call that method because inside the if condition or outside of that i cant called.Please help me.Thanks
1988
I updated my answer to show you how to do that.
jamone
1988