代码中未知的零值 - 斯威夫特



我正在为一个带有菜单的应用程序编写代码,出于某种奇怪的原因,Xcode给了我一个零错误。感谢所有帮助。


//
//  ViewController.swift
//  Menu
//
//  Created by Programmer on 8/1/17.
//  Copyright © 2017 Programmer. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var LeadingConstr1: NSLayoutConstraint!
@IBOutlet weak var MenuView1: UIView!
@IBOutlet weak var LeadingConstr2: NSLayoutConstraint!
@IBOutlet weak var MenuView2: UIView!
var menushowing1 = false;
var menushowing2 = false;
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
MenuView1.layer.shadowOpacity = 1
MenuView1.layer.shadowRadius = 6
MenuView2.layer.shadowOpacity = 1
MenuView2.layer.shadowRadius = 6
}
@IBAction func MenuBtn(_ sender: Any) {
if (menushowing1) {
LeadingConstr1.constant = -140
}
else {
LeadingConstr1.constant = 0
UIView.animate(withDuration: 0.3, animations: {
self.view.layoutIfNeeded()
})
view.layoutIfNeeded()
}
menushowing1 = !menushowing1
}
@IBAction func MenuBtn2(_ sender: Any) {
if (menushowing2) {
LeadingConstr2.constant = -140
}
else {
LeadingConstr2.constant = 0
UIView.animate(withDuration: 0.3, animations: {
self.view.layoutIfNeeded()
})
view.layoutIfNeeded()
}
menushowing2 = !menushowing2
}

}

这是我得到的错误:

致命错误:解开可选值时意外发现 nil 2017-08-03 07:18:40.647621-0400 菜单[383:53946] 致命错误: 解开可选值 (lldb( 时意外发现 nil –

您有一些与任何@IBOutlet Menu无关的出口Menu。从 XIB/情节提要中删除该连接,或在视图控制器中添加变量。

相关内容

  • 没有找到相关文章

最新更新