【发布时间】:2018-07-25 08:34:09
【问题描述】:
class MyView:UIViewController{
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
print(segue.destination)
let distinationVC = segue.destination as? MyTableController
distinationVC?.topConstaints.constant = 0
}
}
class MyTableController: UIViewController, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var topConstaints: NSLayoutConstraint!
}
返回
print(segue.destination)
<myApp. MyTableController:0 x>
但在
中引发异常distinationVC?.topConstaints.constant = 0
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
是不是我做错了什么?
我不知道如何解决这个问题
【问题讨论】:
-
检查topConstaints插座是否正确连接
-
您的 topConstaints 属性为零。在 MyTableController 的 viewDidLoad 方法中设置这个属性。
标签: ios swift uicontainerview