Ios N以模式从其他位置显示UITableViewController时出现异常错误
当我在应用程序中的其他位置显示我的Ios N以模式从其他位置显示UITableViewController时出现异常错误,ios,swift,uitableview,Ios,Swift,Uitableview,当我在应用程序中的其他位置显示我的UITableViewController时,我收到一个错误: libc++abi.dylib:以NSException类型的未捕获异常终止 同样的代码在苹果的默认项目中工作,问题是什么 import UIKit class SettingViewController: UITableViewController { let fruits = ["Apple", "Orange", "Peach"] override func viewDid
UITableViewController
时,我收到一个错误:
libc++abi.dylib:以NSException类型的未捕获异常终止
同样的代码在苹果的默认项目中工作,问题是什么
import UIKit
class SettingViewController: UITableViewController {
let fruits = ["Apple", "Orange", "Peach"]
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return fruits.count
}
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return "Section \(section)"
}
override func tableView(tableView: UITableView,
cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("TextCell", forIndexPath: indexPath)
let fruit = fruits[indexPath.row]
cell.textLabel!.text = "\(indexPath.section).\(indexPath.row): \(fruit)"
return cell
}
}
在viewDidLoad()中,我添加了
放一个盒子看看它在哪里坠毁。我怀疑您没有创建标识符为“TextCell”的单元格错误的原因是libc++abi.dylib:以NSException类型的未捕获异常终止断点位于let cell=tableView.dequeueReusableCellWithIdentifier(“reuseIdentifier”,forIndexPath:indexPath)我怀疑这确实解决了OP的问题,因此,它确实为这个问题提供了答案。但是代码中的reuseIdentifier是“TextCell”,这里您使用标识符“reuseIdentifier”注册一个单元格。
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "reuseIdentifier")