當我提出我的UITableViewController
從modaly的其他地方的應用程序,我得到一個錯誤:NSException錯誤從其他地方呈現的UITableViewController當模態
libc++abi.dylib: terminating with uncaught exception of type 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
}
}
在[異常斷點]把(https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint .html)查看它崩潰的位置。我懷疑你沒有創建一個標識符爲「TextCell」的單元格 – shim
錯誤原因libC++ abi.dylib:終止於類型爲NSException的未捕獲異常 – David
斷點在 let cell = tableView.dequeueReusableCellWithIdentifier(「reuseIdentifier 「,forIndexPath:indexPath) – David