Cargue varias celdas prototipo en UITableView
Actualmente tengo un UITableView que contiene 2 filas de una celda personalizada. Recientemente agregué una segunda celda prototipo a mi guión gráfico e intenté agregarla a mi UITableView sin éxito. Mi método cellForRowAtIndexPAth es el siguiente:
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
}
La Sección 0 y la Sección 1 cargan correctamente la celda prototipo con la ID "Celda", pero cuando voy a cargar la sección 2 obtengo otra instancia de la primera celda prototipo menos datos ya que no se le ha asignado un delegado o dataSource. De lo contrario, las celdas se configuran de forma idéntica con los ID de "Cell" y "Cell2" respectivamente, pero parece que no puedo acceder a "Cell2".
Aclaración adicional: tengo 2 celdas prototipo en mi guión gráfico, ambas están configuradas de la misma manera que ambas tienen sus identificadores etiquetados en los mismos cuadros, heredan de sus propias clases y han sido declarados iguales en mi UITableView. En cuanto a los delegados y dataSources, mi celda prototipo original contiene un gráfico (usa BEMSimpleLineGraph), cada instancia de esta celda tiene su propio delegado y fuente de datos y se muestra en el código anterior para las acciones 0 y 1.
La primera celda que se muestra a continuación (en gris) es la celda original que contiene un gráfico y la celda2 está justo debajo de ella en blanco.