IndexPathForRow(at: point) каждый раз возвращает 0
У меня есть табличное представление в ряду другого табличного представления. В cellforRowat indexPath моего внутреннего табличного представления я хочу иметь возможность получить indexpath внешнего табличного представления.
Я старался:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCell(withIdentifier: "Answer") as? MCAnswerCell
{
if let index = self.tableView?.indexPath(for: self){
// self is a custom cell used in the outer tableview
}
}
}
Но это возвращает ноль для строк, которых нет на экране. Итак, я собирался попытаться использовать следующее:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCell(withIdentifier: "Answer") as? MCAnswerCell
{
if let index = self.tableView?.indexPathForRow(at: cell.center){
//returns 0 every time
}
}
}