что мне нужно, это прокрутить строку в разделе в tableView, когда вызывается viewDidAppear.Я создал это простое приложение для тестирования.Я пытаюсь выяснить, почему происходит сбой при попытке использовать scrollToRow.Это сбой в AppDelegate ---- Ошибка потока 1: сигнал SIGABRT
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
let tableView = UITableView()
let section = 2
let row = 3
let data = ["Cat", "Dog", "Bird", "Cow", "Owl", "Deer", "Rabbit", "Bull", ]
@IBOutlet weak var myTable: UITableView!
override func viewDidAppear(_ animated: Bool) {
// Crash in AppDelegate ---- Error Thread 1: signal SIGABRT
tableView.scrollToRow(at: IndexPath(row: row, section: section), at: UITableView.ScrollPosition.top, animated: true)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
func numberOfSections(in tableView: UITableView) -> Int {
return data.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
cell.textLabel!.text = data[indexPath.row]
return cell
}
}