2012-10-18 47 views
0

我无法编程AlertView以推送到新的ViewController。我跟着几个教程,仍然无法正常工作。任何帮助,将不胜感激。尝试使用AlertView推送到另一个视图控制器

- (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]; 
    } 
} 
+0

您需要在其生命周期中保留alertview。该版本将打破它。 –

回答

1

您应该使用UIAlertView委托

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

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

,并检查self.navigationController不nil

相关问题