不推荐使用UIAlertView

不推荐使用UIAlertView

本文介绍了不推荐使用UIAlertView:首先在iOS 9.0中弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I keep getting errors on Xcode, how do i help this?

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

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

Here i get 'presentModalViewController:animated' is deprecated. First deprecated in IOS 6.0.

-(IBAction)SetMap:(id)sender {

我不推荐使用'UIAlertView':在iOS 9.0中首先弃用 - 不推荐使用UIAlertView。改为使用UIAlertController和UIAlertControllerStyleAlert的preferredStyle。

Here i get 'UIAlertView' is deprecated: first deprecated in iOS 9.0 - UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead.

}

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

And after the curly bracket i get 'dismissModalViewControllerAnimated:' is deprecated: first deprecated in 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。

And at last i get 'dismissModalViewControllerAnimated:' is deprecated: first deprecated in iOS 6.0.

推荐答案

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

You're getting these warnings/errors because those methods have been removed from the code base. I'm guessing you're trying to follow along with an old tutorial.

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

You should also post more of your code. What you have shown us is not where your warnings/errors are.

对于 dismissModalViewControllerAnimated 请改用它。 / p>

For the dismissModalViewControllerAnimated use this instead.

[self dismissViewControllerAnimated:YES completion:nil];

对于 presentModalViewController:animated 使用此。

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

最后,对于你UIAlertView,你现在应该使用UIAlertController:

Finally, for you UIAlertView you should now be using a 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];

这篇关于不推荐使用UIAlertView:首先在iOS 9.0中弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 02:15