gpt4 book ai didi

ios - 从尝试填充 TableView 中获取 SIGABRT

转载 作者:行者123 更新时间:2023-11-28 09:50:28 26 4
gpt4 key购买 nike

我有一个 TableView ,需要用动态数据填充。

我之前是在一个单独的 Controller 中完成的,只是复制了所有内容。

但是,这次我不断收到 SIGABRT 错误。我发现每当我包含这两行时它都会出错

//  editJobTable.dataSource = self
// editJobTable.delegate = self

这是我的全 View Controller

import Foundation
import UIKit

class HelloworkJobsEditJobViewController: UIViewController{
fileprivate var presenter: HelloworkJobsEditJobPresenter?

@IBOutlet weak var editJobTable: UITableView!

func inject(presenter: HelloworkJobsEditJobPresenter) {
self.presenter = presenter
}

var helloworkJob: HelloworkJob!

override func viewDidLoad(){
super.viewDidLoad()
helloworkJob = presenter?.getHelloworkJob()
editJobTable.dataSource = self
editJobTable.delegate = self
// editJobTable.reloadData()
}

@IBAction func tapCloseButton(_ sender: Any) {
self.dismiss(animated: true, completion: nil)
}
}

extension HelloworkJobsEditJobViewController: UITableViewDataSource {

func numberOfSections(in tableView: UITableView) -> Int {
return 1
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return 7
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
print("\(#line): \(#function) \(indexPath.row)")
let cellIdentifier = "HelloworkJobsEditJobCell"

guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? HelloworkJobsEditJobCell else {
fatalError("The dequeued cell is not an instance of HelloworkJobsEditJobCell.")
}

cell.cellLabel.text = "labeltest"
cell.cellTextField.text = "textfieldtest"
return cell
}
}

extension HelloworkJobsEditJobViewController: UITableViewDelegate {
}

任何关于它可能抛出此错误的想法将不胜感激。

最佳答案

您必须使用单元格自定义类注册 tableView

tableView.register(UINib(nibName: "engineTableViewCell", bundle: nil), forCellReuseIdentifier:"cellID")

或者

tableView.register(engineTableViewCell.self, forCellReuseIdentifier: "cellID")

关于ios - 从尝试填充 TableView 中获取 SIGABRT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49529570/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com