相关疑难解决方法(0)

UIAlertView首先弃用了IOS 9

我尝试了几种方法来使用UIAlertController而不是UIAlertView.我尝试了几种方法,但我无法使警报行动起作用.这是我的代码在IOS 8和IOS 9中正常工作,但是出现了弃用的标志.我尝试了下面的优雅建议,但我无法在此背景下使其发挥作用.我需要提交我的应用程序,这是最后要解决的问题.感谢您的任何进一步建议.我是新手.

#pragma mark - BUTTONS ================================
- (IBAction)showModesAction:(id)sender {
NSLog(@"iapMade: %d", iapMade3);

// IAP MADE ! ===========================================
if (!iapMade3) {

    //start game here
    gamePlaysCount++;
    [[NSUserDefaults standardUserDefaults]setInteger:gamePlaysCount forKey:@"gamePlaysCount"];
    NSLog(@"playsCount: %ld", (long)gamePlaysCount);

    if (gamePlaysCount >= 4) {
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Basic"
                                                     message: THREE_PLAYS_LIMIT_MESSAGE
                                                    delegate:self
                                           cancelButtonTitle:@"Yes, please"
                                           otherButtonTitles:@"No, thanks", nil];
       [alert show];

        NSString *path = [[NSBundle mainBundle] pathForResource:@"cow" ofType:@"wav"];
        _pop =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
        [_pop play];
        [self dismissViewControllerAnimated:true completion:nil];

    } else {
        if (gamePlaysCount == 1)  {
            // Create …
Run Code Online (Sandbox Code Playgroud)

objective-c uialertview ios uialertcontroller

104
推荐指数
5
解决办法
11万
查看次数

WKWebView Alert 在 iOS 13 SceneDelegate 上崩溃

*** 由于未捕获的异常“NSObjectNotAvailableException”而终止应用程序,原因:“UIAlertView 已弃用且不可用于基于 UIScene 的应用程序,请使用 UIAlertController!”

从 WKWebView 发出警报时,它会引发上述错误。

UIAlertView 是从网页中的 Javascript 调用的。我没有手动调用 UIAlertView。

import UIKit
import WebKit

class ViewController: UIViewController{

    @IBOutlet weak var webView: WKWebView!
    override func viewDidLoad() {
        super.viewDidLoad()

        let url = URL(string: "https://www.google.com/maps")!
        webView.load(URLRequest(url: url))
    }
}
Run Code Online (Sandbox Code Playgroud)

当我单击“您的位置”时加载地图后,应用程序崩溃。

uialertview ios swift uialertcontroller ios13

2
推荐指数
1
解决办法
2206
查看次数

标签 统计

ios ×2

uialertcontroller ×2

uialertview ×2

ios13 ×1

objective-c ×1

swift ×1