こんにちは、私のView Controllerには、複数のボタンを持つ2つのアラートビューがあり、これらのボタンは別のメソッドをトリガーします。次のコードを使用しますが、
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
このメソッドは呼び出しではありません。これは私が使用したコード全体です
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.section==1)
{
if(indexPath.row==0)
{
GMMAboutUsViewController *aboutus= [self.storyboard instantiateViewControllerWithIdentifier:@"aboutus"];
[self.navigationController pushViewController:aboutus animated:YES];
}
else if (indexPath.row==1)
{
GMMTermsOfServiceViewController *termsofservice= [self.storyboard instantiateViewControllerWithIdentifier:@"termsofservice"];
[self.navigationController pushViewController:termsofservice animated:YES];
}
else if (indexPath.row==2)
{
GMMUserGuideViewController *userguide= [self.storyboard instantiateViewControllerWithIdentifier:@"userguide"];
[self.navigationController pushViewController:userguide animated:YES];
}
else
{
GMMCreditsandCopyrightsViewController *creditsandcopyrights= [self.storyboard instantiateViewControllerWithIdentifier:@"creditsandcopyrights"];
[self.navigationController pushViewController:creditsandcopyrights animated:YES];
}
}
else
{
if(indexPath.row==0)
{
alertDeregister=[[UIAlertView alloc]
initWithTitle:@"Deregister"
message:@"Are you sure you want to Deregister ? "
delegate:nil
cancelButtonTitle:@"NO"
otherButtonTitles:nil, nil];
alertDeregister.tag=kFirstAlertViewTag;
[alertDeregister addButtonWithTitle:@"YES"];
[alertDeregister show];
}
else
{
alertLogout=[[UIAlertView alloc]
initWithTitle:@"Logout"
message:@"Are you sure you want to logout ? "
delegate:nil
cancelButtonTitle:@"cancel"
otherButtonTitles:nil, nil];
alertLogout.tag=kSecondAlertViewTag;
[alertLogout addButtonWithTitle:@"Logout"];
[alertLogout show];
}
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if(alertView==alertDeregister)
{
if(buttonIndex==0)
{
[self deregister];
}
}
else if (alertView==alertLogout)
{
if(buttonIndex==0)
{
GMMLoginController *login = [self.storyboard instantiateViewControllerWithIdentifier:@"l"];
[self presentModalViewController:login animated:NO];
}
}
}