I am new in iPhone developer,
I want to implement 2 alert view one after another, like when user press delete button, 1st alert view will ask Are you sure want to Delete ?
with two buttons yes
and no
Now, if user presses yes
, then 2nd alert view will come with message Deleted Successfully !
this alert view contains only OK
button, now on click of this OK
button i want to call one method.
and if user presses No
then nothing should happen and alert should dismiss.
Here is my code snippet,
-(void)DeletebtnCliked:(id)sender
{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Are you sure want to delete ?"
message:nil delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Yes",@"No",nil];
[alertView show];
[alertView release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
UIAlertView* alertew = [[UIAlertView alloc] initWithTitle:@"Deleted Successfully !"
message:nil delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertew show];
[alertew release];
if (buttonIndex == 0)
{
[self MethodCall];
}
}
else if (buttonIndex == 1)
{
[alertView dismissWithClickedButtonIndex:1 animated:TRUE];
}
}
after writing this code i am inside Infinite loop.
Any help will be appreciated.
alertView.tag = 1;
alertew.tag = 2;
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag == 2)
{
//Do something
}
else
{
//Do something else
}
}