gpt4 book ai didi

ios - 尝试使用 AlertView 推送到另一个 View Controller

转载 作者:行者123 更新时间:2023-11-29 04:21:17 24 4
gpt4 key购买 nike

我在编写 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];
}
}

最佳答案

您应该使用UIAlertView委托(delegate)

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

不是

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

并检查 self.navigationController 是否为 nil

关于ios - 尝试使用 AlertView 推送到另一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12962196/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com