我使用 MRProgress
提供一个加载屏幕,该屏幕可以在我以前的应用程序中使用,但在另一个 ViewController 中实现它不起作用,我不知道为什么。
var progressView: MRProgressOverlayView?
override func viewDidLoad() {
super.viewDidLoad()
print(" seconds to the end of the world")
progressView = MRProgressOverlayView.showOverlayAdded(to: UIApplication.shared.windows.first!, title: "", mode: .indeterminate, animated: true)
}
如有任何帮助,我将不胜感激。
最佳答案
它没有显示,因为您使用 UIApplication.shared.windows.first!
将其分配给错误的 View ,因此将其替换为 self.view
,您的代码将是:
progressView = MRProgressOverlayView.showOverlayAdded(to: self.view, title: "", mode: .indeterminate, animated: true)
编辑:
查看演示项目 HERE
你的结果将是:
在演示项目中,我已将 pod 'MRProgress'
安装到项目中,ViewController.swift
文件代码将是:
import UIKit
import MRProgress
class ViewController: UIViewController {
var progressView: MRProgressOverlayView?
override func viewDidLoad() {
super.viewDidLoad()
progressView = MRProgressOverlayView.showOverlayAdded(to: self.view, title: "", mode: .indeterminate, animated: true)
}
}
关于swift - 快速显示进度 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54726502/