0

我在编写 AlertView 以推送到新的 ViewController 时遇到问题。我已经遵循了几个教程,但仍然无法使其正常运行。任何帮助,将不胜感激。

- (IBAction)web:(id)sender {
    UIAlertView *testAlert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"You are now entering a website outside of the Company App: Any links or references to other Internet sites (hyperlinks) are provided by Company merely as a convenience to users of this App." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Proceed", nil];

        [testAlert show];
        [testAlert release];

}

-(void)web:(UIAlertView *)web clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (buttonIndex == 0) {
    }
    else if (buttonIndex == 1) {

    JBWebViewController *jbweb = [[JBWebViewController alloc] initWithNibName:@"JBWebViewController" bundle:nil];
        [self.navigationController pushViewController:jbweb animated:YES];
    }
}
4

1 回答 1

1

你应该使用UIAlertView委托

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

不是

-(void)web:(UIAlertView *)web clickedButtonAtIndex:(NSInteger)buttonIndex

并检查 self.navigationController 不是nil

于 2013-10-07T02:20:53.380 回答