不推荐使用UIAlertView:首先在iOS 9.0中弃用

我一直在Xcode上遇到错误,我该如何帮助?

- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } 

这里我得到’presentModalViewController:animated’不推荐使用。 首先在IOS 6.0中弃用。

 -(IBAction)SetMap:(id)sender { 

在这里我得到’UIAlertView’不推荐使用:首先在iOS 9.0中弃用 – UIAlertView已被弃用。 使用UIAlertController而不是UIAlertControllerStyleAlert的preferredStyle。

 } 

在大括号后我得到’dismissModalViewControllerAnimated:’不推荐使用:首先在iOS 6.0中弃用。

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

最后我得到’dismissModalViewControllerAnimated:’不推荐使用:首先在iOS 6.0中弃用。

您收到这些警告/错误,因为这些方法已从代码库中删除。 我猜你正在尝试按照旧的教程。

您还应该发布更多代码。 你告诉我们的不是你的警告/错误所在。

对于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];