我试图在用户单击带有警告的按钮时出现一个弹出窗口,如果他们单击取消,它将被关闭,但如果他们单击继续,我希望它显示视图控制器。这是我的代码,但无论我按下哪个按钮,它都只会关闭弹出窗口:
- (IBAction)latest:(id)sender {
alert = [[UIAlertView alloc] initWithTitle:@"WARNING" message:@"Continuing will use internet and may cause app to slow down in large crowds" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Continue", nil];
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 2) {
UIViewController *NVC = [self.storyboard instantiateViewControllerWithIdentifier:@"Latest"];
[self presentViewController:NVC animated:YES completion:Nil];
}
}