不推荐使用UIAlertView:iOS 9.0中不推荐使用

Cla*_*sen 1 xcode uialertview viewcontroller ios

我在Xcode上不断收到错误,我该如何帮助呢?

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
Run Code Online (Sandbox Code Playgroud)

在这里,我不赞成使用'presentModalViewController:animated'。在IOS 6.0中首次弃用。

-(IBAction)SetMap:(id)sender {
Run Code Online (Sandbox Code Playgroud)

在这里,我不赞成使用'UIAlertView':在iOS 9.0中不赞成使用-UIAlertView不赞成使用。改用UIAlertController和UIAlertControllerStyleAlert的preferredStyle。

}
Run Code Online (Sandbox Code Playgroud)

在花括号之后,我不赞成使用“ 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"]];
}
Run Code Online (Sandbox Code Playgroud)

最后,我不赞成使用“ dismissModalViewControllerAnimated:”:在iOS 6.0中第一次不赞成使用。

Bea*_*lle 7

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

您还应该发布更多代码。您向我们展示的内容并不是您的警告/错误所在。

为了dismissModalViewControllerAnimated使用它代替。

[self dismissViewControllerAnimated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

为此presentModalViewController:animated使用。

[self presentViewController:newController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

最后,对于您的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];
Run Code Online (Sandbox Code Playgroud)