嗨,在我的视图控制器中,有两个带有多个按钮的警报视图,这些按钮将触发另一种方法。所以我使用以下代码,但
- (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];
}
}
}