Carregar várias células de protótipo no UITableView
Atualmente, tenho um UITableView contendo 2 linhas de uma célula personalizada. Recentemente, adicionei uma segunda célula protótipo ao meu storyboard e tentei adicioná-la ao meu UITableView sem sucesso. Meu método cellForRowAtIndexPAth é o seguinte:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: FlightsDetailCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as FlightsDetailCell
cell.userInteractionEnabled = false
if indexPath.section == 0 {
cell.graphView.enableBezierCurve = true
cell.graphView.enableReferenceYAxisLines = true
cell.graphView.enableYAxisLabel = true
cell.graphView.colorYaxisLabel = UIColor.whiteColor()
cell.graphView.delegate = UIApplication.sharedApplication().delegate as BEMSimpleLineGraphDelegate
cell.graphView.dataSource = UIApplication.sharedApplication().delegate as BEMSimpleLineGraphDataSource
return cell
}
if indexPath.section == 1 {
cell.graphView.enableBezierCurve = true
cell.graphView.enableReferenceYAxisLines = true
cell.graphView.enableYAxisLabel = true
cell.graphView.colorYaxisLabel = UIColor.whiteColor()
cell.graphView.delegate = self
cell.graphView.dataSource = self
return cell
}
if indexPath.section == 2 {
let cell2: FlightsInformationCell = tableView.dequeueReusableCellWithIdentifier("Cell2", forIndexPath: indexPath) as FlightsInformationCell
cell2.userInteractionEnabled = false
return cell2
}
return cell
}
A Seção 0 e a Seção 1 carregam corretamente a célula protótipo com o ID "Cell", mas quando vou carregar a seção 2, recebo outra instância da primeira célula protótipo, menos os dados, pois não foi atribuído um delegado ou fonte de dados. Caso contrário, as células são configuradas de forma idêntica aos IDs de "Cell" e "Cell2", respectivamente, mas não consigo acessar o "Cell2".
Esclarecimento adicional: Eu tenho duas células protótipo no meu storyboard, ambas são iguais e ambos têm seus identificadores rotulados nas mesmas caixas, herdam de suas próprias classes e foram declarados o mesmo no meu UITableView. Quanto aos delegados e dataSources, minha célula protótipo original contém um gráfico (usa BEMSimpleLineGraph), cada instância dessa célula possui seu próprio delegado e fonte de dados e é mostrada no código acima para as ações 0 e 1.
A primeira célula mostrada abaixo (em cinza) é a célula original que contém um gráfico e a célula2 está logo abaixo em branco.