UIAlertView 已弃用且不适用于基于 UIScene 的应用程序,请使用 UIAlertController [英] UIAlertView is deprecated and unavailable for UIScene based applications, please use UIAlertController

查看:31
本文介绍了UIAlertView 已弃用且不适用于基于 UIScene 的应用程序,请使用 UIAlertController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Swift 的新手,遇到了这个错误.

I'm new to Swift and I'm getting this Error.

我不明白,因为我的代码中没有使用任何类型的警报.

I don't get it because I don't use any type of alert in my code.

这是我的视图控制器:

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))
    }
}

我只想在我的应用中使用 WKWebView 并使用位置.

I only want to use WKWebView in my app and use the location.

我已经将 NSLocationAlwaysAndWhenInUseUsageDescription 添加到 info.plist

如果您使用 iOS 13、Xcode 和此示例,则可以重现此错误以及任何使用该位置的网站,例如谷歌地图.

You can reproduce this error if you using iOS 13, Xcode and this example and any website which uses the location like google maps.

推荐答案

我也遇到了同样的问题,我能够从开发人员那里得到帮助解决它,场景基础应用程序是新的但不支持 ui 警报视图所以它崩溃了应用程序,我们可以删除我们可以使用窗口基础应用程序的场景基础应用程序,请按照以下步骤解决问题:

I was also going through the same issue, i'm able to solve it getting help from a developer, scene base application that is new yet not support ui alert view so it crashes the app, we can remove the scene base application we can use window base app, follow these steps to resolve the issue:

首先删除SceneDelegate文件第一步检查这张图片其次从 AppDelegate 文件中删除 UISceneSession Lifecycle 两个方法第二步检查这张图片第三次转到您的信息 plist 并从中删除应用程序场景清单条目第三步检查这张图片继续构建项目,现在运行它,确保 AppDelegate 中有 window 属性

First remove the SceneDelegate file check this image for first step Second remove UISceneSession Lifecycle two methods from AppDelegate file check this image for second step Third go to your info plist and remove Application Scene Manifest Entry from it check this image for third step Go ahead and build the project, run it now, make sure you have window property in AppDelegate

这篇关于UIAlertView 已弃用且不适用于基于 UIScene 的应用程序,请使用 UIAlertController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆