-2

我正在尝试集成 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))
    }


}
4

1 回答 1

0

我的猜测是您的 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

于 2021-05-06T07:00:08.193 回答