我的Swift程序崩溃了EXC_BAD_INSTRUCTION,这个错误.它是什么意思,我该如何解决?
致命错误:在展开Optional值时意外发现nil
这篇文章旨在收集"意外发现的零"问题的答案,因此它们并不分散且难以找到.随意添加自己的答案或编辑现有的维基答案.
任何人都可以看到为什么世界上没有调用SelectRowAtIndexPath会被调用?我delegate在代码和故事板中都进行了三重检查.
class AddCard: UIViewController,UIPopoverPresentationControllerDelegate, UITableViewDataSource, UITableViewDelegate {
@IBOutlet weak var cardView: UIView!
@IBOutlet weak var tableView: UITableView!
let tableItems = ["Background Color","Background Image","Font Style","Font Color"]
let cellID = "cell"
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func setBackgroundColor (_ color: UIColor) {
cardView.backgroundColor = color
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: …Run Code Online (Sandbox Code Playgroud)