ios - 为什么SVProgressHUD会抛出eorrr?
问题描述
我正在尝试集成 SVProgressHUD 库,并希望在我的控制器上的 API 响应之前显示我已经编写了一个代码,但它抛出了一个错误,如Thread 1: "-[MYOWEB.AppDelegate window]: unrecognized selector sent to instance 0x600001bc2a40 "
//ViewController.swift
import UIKit
import SVProgressHUD
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
SVProgressHUD.setDefaultMaskType(.clear)
SVProgressHUD.setDefaultStyle(.custom)
SVProgressHUD.setForegroundColor(UIColor.white)
SVProgressHUD.setBackgroundColor(#colorLiteral(red: 0.1333333333, green: 0.3764705882, blue: 0.9960784314, alpha: 1).withAlphaComponent(1))
}
}
解决方案
我的猜测是您的 AppDelegate.swift 没有 window 属性。即'让窗口; UIWindow' 该库依赖于它,请参见此处的第 72 行 https://github.com/SVProgressHUD/SVProgressHUD/blob/master/SVProgressHUD/SVProgressHUD.m
查看示例演示应用程序以获取更多详细信息 https://github.com/SVProgressHUD/SVProgressHUD/blob/master/Demo/Classes/AppDelegate.h
推荐阅读
- qt - 如何使 QTreeView 显示不在第一列的子树
- python - 如何在 python 中处理 TypeError?
- c# - C# POST 甚至多次运行方法,但应该只运行一次
- c# - 生成 ListViewItem 时,如何更改此“签入”按钮的颜色?
- java - 如何在 intellij 中查看静态字符串常量的连接值
- json - 如何在 Swift 中从 JSON 中解码大量数字
- python - 规范化 dict 中 Counter 值的最有效方法
反对所有的钥匙? - jsf - 当 dynamic 设置为 true 时,Primefaces 对话框为空白
- python-3.x - 如何在 python 脚本中编写“脚本”bash 命令来记录我的输出
- c# - 如何使用 .Net Core 从 Elipse 服务器检索数据?我是否受限于使用 DLL 的 .NET Framework?