Ios UIview中的两个表视图出现致命错误
在我的应用程序中,我想在UIViewController中显示两个表视图,但我有一个致命错误:致命错误:在展开可选值时意外发现nil 有人能帮我吗 以下是uiview的完整代码 类MyPropertiesViewController:UIViewController、UITableViewDelegate、UITableViewDataSource{ //细胞识别器 让stdcellIdentifier=“stdcell” }Ios UIview中的两个表视图出现致命错误,ios,swift,uitableview,Ios,Swift,Uitableview,在我的应用程序中,我想在UIViewController中显示两个表视图,但我有一个致命错误:致命错误:在展开可选值时意外发现nil 有人能帮我吗 以下是uiview的完整代码 类MyPropertiesViewController:UIViewController、UITableViewDelegate、UITableViewDataSource{ //细胞识别器 让stdcellIdentifier=“stdcell” } 谢谢检查您的单元格类是否真的是GuaranteeCell(可能存在错
谢谢检查您的单元格类是否真的是GuaranteeCell(可能存在错误)尝试将为tableViewcell注册而编写的viewDidLoad代码移动到ViewWillDisplay方法,并尝试将这两个表视图正确连接到您的故事板中?我已经检查过,两个tableview的单元格都是GuaranteeCell
//table view extended
@IBOutlet weak var extandedTableViex: UITableView!
// table view standart
@IBOutlet weak var standartTableView: UITableView!
//list of data
let stdlist = ["1","2","3", "4","5","6","7","8","9"]
let Extlist = ["E1","E2" ]
let extcellIdentifier = "extcell"
override func viewDidLoad() {
super.viewDidLoad()
standartTableView.delegate = self
standartTableView.dataSource = self
standartTableView.delegate = self
standartTableView.dataSource = self
standartTableView.scrollEnabled = false
extandedTableViex.scrollEnabled = false
self.standartTableView.registerClass(GuaranteeCell.self, forCellReuseIdentifier: stdcellIdentifier)
self.extandedTableViex.registerClass(GuaranteeCell.self, forCellReuseIdentifier: extcellIdentifier)
}
//count cell
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == standartTableView {
return self.stdlist.count;
} else {
return self.Extlist.count;
}
}
// add cell
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
if tableView == standartTableView {
let cell:GuaranteeCell = self.standartTableView.dequeueReusableCellWithIdentifier(stdcellIdentifier) as! GuaranteeCell
print("list-element " + self.stdlist[indexPath.row])
print(indexPath.row)
cell.guaranteeLabel.text = self.stdlist[indexPath.row]
return cell
} else {
let cell2:GuaranteeCell = self.extandedTableViex.dequeueReusableCellWithIdentifier(extcellIdentifier) as! GuaranteeCell
cell2.guaranteeLabel.text = String(self.Extlist[indexPath.row])
return cell2
}
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { }
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}