Я пытаюсь выбрать первую строку в UITableViewController после ее появления (через segue).Выбор первой строки в UITableViewController в Swift
Я использую следующий код, который я унаследовал от моего предыдущего Цель проекта C:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let customCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! IGANavlistTableCustomViewCell
// Code that sets the custom view cell
// Then...
// Selecting the first row by default
if(indexPath.row == 0)
{
let rowToSelect:NSIndexPath = NSIndexPath(forRow: 0, inSection: 0)
tableView.selectRowAtIndexPath(rowToSelect, animated: true, scrollPosition: UITableViewScrollPosition.None)
tableView.delegate?.tableView!(tableView, didSelectRowAtIndexPath: rowToSelect)
}
return customCell;
}
Я получаю следующее сообщение об ошибке:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[IGANavlistTableVC tableView:didSelectRowAtIndexPath:]: unrecognized selector sent to instance 0x79e21040'
Я был бы признателен, если кто-то может помочь.
Спасибо!
EDIT:
Это мой метод didDeselectRowAtIndexPath:
var navaidSelected = [String]()
var listOfNavPoints = [[String]]()
override func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath)
{
// The selected object of the Array with all navaids data (i.e., the selected navaid) is converted to a string
self.navaidSelected = self.listOfNavPoints[indexPath.row]
}
Вы используете раскадровку? Правильно ли все подключено? –
Ошибка указывает на didSelectRowAtIndexPath. Можете ли вы показать код для этого? –