UIAlertView已弃用:首次在iOS 9.0中弃用

UIAlertView已弃用:首次在iOS 9.0中弃用,ios,xcode,uialertview,viewcontroller,Ios,Xcode,Uialertview,Viewcontroller,我一直在Xcode上出错,我该如何帮助呢 - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } 这里我得到的“presentModalViewController:animated”是不推荐的。首次在IOS 6.0中被弃用 -(IBAction)SetMap:(id)sender { 这里我得到的“UIAlertView”已被弃用:iOS 9.0中的第一个弃用-UIAlertView已弃用。改用UIAlert

我一直在Xcode上出错,我该如何帮助呢

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
这里我得到的“presentModalViewController:animated”是不推荐的。首次在IOS 6.0中被弃用

-(IBAction)SetMap:(id)sender {
这里我得到的“UIAlertView”已被弃用:iOS 9.0中的第一个弃用-UIAlertView已弃用。改用UIAlertController的首选样式UIAlertControllerStyleAlert

}
在花括号之后,我得到了“dismissModalViewControllerAnimated:”是不推荐使用的:第一个在iOS 6.0中不推荐使用

- (IBAction)Aktiekurs:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.euroinvestor.dk/boerser/nasdaq-omx-copenhagen/novozymes-b-a-s/239698"]];
}

最后,我得到了“dismissModalViewControllerAnimated:”已弃用:第一次在iOS 6.0中弃用。

您收到这些警告/错误,因为这些方法已从代码库中删除。我猜你是想跟着一个老教程走

- (IBAction)Aktiekurs:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.euroinvestor.dk/boerser/nasdaq-omx-copenhagen/novozymes-b-a-s/239698"]];
}
您还应该发布更多的代码。您向我们展示的不是警告/错误所在的位置

对于dismissModalViewControllerAnimated,请使用此选项

[self dismissViewControllerAnimated:YES completion:nil];
对于
presentModalViewController:animated
,请使用此选项

[self presentViewController:newController animated:YES completion:nil];
最后,对于UIAlertView,您现在应该使用UIAlertController:

UIAlertController *alertController = [UIAlertController
                              alertControllerWithTitle:@"title"
                              message:@"some message"
                              preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction *cancelAction = [UIAlertAction 
            actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action")
                      style:UIAlertActionStyleCancel
                    handler:^(UIAlertAction *action)
                    {
                      NSLog(@"Cancel action");
                    }];

UIAlertAction *okAction = [UIAlertAction 
            actionWithTitle:NSLocalizedString(@"OK", @"OK action")
                      style:UIAlertActionStyleDefault
                    handler:^(UIAlertAction *action)
                    {
                      NSLog(@"OK action");
                    }];

[alertController addAction:cancelAction];
[alertController addAction:okAction];

[self presentViewController:alertController animated:YES completion:nil];

这就是我在ViewController.m中的全部内容,可能是因为我遵循了一些旧教程,但其中一个我无法正常工作。所以我删除了我写的代码。但这与此无关,对吗?:)但是我可以发送viewcontroller.h中的内容?你说你在哪里收到这些警告是没有意义的。如果这是您所有的代码,那么如果您的代码甚至没有使用UIAlertView,您如何获得“'UIAlertView'已弃用”。如果您以前在那里有此代码,然后将其删除,我可以看到警告如何仍然保留。做一次清理,并尝试重建你的项目,他们可能会离开。谢谢你的帮助,博。我做了清理重建,它成功了。没问题,如果你觉得有帮助,一定要点击我答案上的勾号,不要介意你得到的反对票,我知道你在说什么:)