Я создаю приложение с несколькими сценами и табличным представлением с пользовательскими ячейками в каждой.Я получил представление таблицы на домашнем экране, чтобы работать нормально, а затем я перехожу к новой сцене из пользовательских ячеек.Когда это происходит, мой второй контроллер вида падает.
Вот мой код для контроллера вида
import UIKit
class QuestionViewController: UIViewController {
@IBOutlet weak var questionLabel: UILabel!
@IBOutlet weak var submitButton: UIButton!
@IBOutlet weak var qTableView: UITableView!
var answers : [QuestionOption] = []
override func viewDidLoad() {
super.viewDidLoad()
answers = [QuestionOption(text: "test"), QuestionOption(text: "test"), QuestionOption(text: "test"), QuestionOption(text: "test")]
qTableView.delegate = self
qTableView.dataSource = self
submitButton.setTitle("Submit", for: .normal)
questionLabel.text = "test question"
}
}
extension QuestionViewController: UITableViewDataSource, UITableViewDelegate{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return answers.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let a = answers[indexPath.row]
let cell = qTableView.dequeueReusableCell(withIdentifier: "QuestionOptionCell") as! QuestionOptionCell
cell.setOption(option: a)
return cell
}
}
Вот мой код для ячейки
import UIKit
class QuestionOptionCell: UITableViewCell {
@IBOutlet weak var cellTitle: UILabel!
func setOption(option: QuestionOption){
cellTitle.text = option.text
}
}
Вот мойкод для класса QuestionOption
import Foundation
import UIKit
class QuestionOption{
var text: String
init(text: String){
self.text = text
}
}
Журнал сбоев
2019-02-20 14:33:28.394695-0800 iQuiz[8935:822409] *** NSForwarding: warning: object 0x7fd608407c40 of class 'iQuiz.QuestionOption' does not implement methodSignatureForSelector: -- trouble ahead
Unrecognized selector -[iQuiz.QuestionOption initWithCoder:]
2019-02-20 14:33:28.395281-0800 iQuiz[8935:822409] Unrecognized selector -[iQuiz.QuestionOption initWithCoder:]
Вот моя раскадровка, если это вообще поможет ![enter image description here](https://i.stack.imgur.com/WSAIs.png)
I 'Мы убедились, что мой идентификатор совпадает, и у меня нет посторонних или неподключенных розеток. Это единственное решение этой проблемы, которое я могу найти в Интернете.