我对此感到疯狂......希望你能帮助我。 我想做的是从我的名为“myPDF”的自定义类更新 UIProgressView(有一种将 PDF 转换为图形的方法)。
UIProgressView 应显示转换的进度... 但我收到一个 fatal error :
“解包可选值时意外发现 nil”
这是我的自定义类:
protocol DataEnteredDelegate {
func loadingInformation (PDFprogress: Float, TextLabel: String)
}
class myPDF {
var delegate: DataEnteredDelegate?
var imageArray:[UIImage] = []
var PDFname: String
var progressPDF: Float = 0
{
didSet{
let textconvert = String(progressPDF)
delegate!.loadingInformation(progressPDF,TextLabel: textconvert)
print("value from progressPDF: \(progressPDF)")
}
}
这就是我的 viewController.swift:
class initViewController: UIViewController, DataEnteredDelegate{
@IBOutlet var progressBar: UIProgressView!
@IBOutlet var startButton: UIButton!
@IBOutlet var textLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
loadingInformation(0, TextLabel: "0")
}
func loadingInformation (PDFprogress: Float, TextLabel: String) {
progressBar.progress = PDFprogress
textLabel.text = TextLabel
print(PDFprogress)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
最佳答案
不清楚,你在哪里得到这个错误,但检查你的“隐式解开的选项”——带有感叹号的变量。 一个或多个未初始化。
关于ios - 从自定义类更新 UIProgressView 出现错误可选展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35915529/