Realicé un UITableViewCell
personalizado en Interface Builder (Storyboard) y lo importé a mi proyecto a través del #import CustomTableViewCell.h
.Personalizado UITableViewCell (IB) solo se muestra en el estado seleccionado
Todo funciona bien, pero la celda solo se carga en estado seleccionado.
Quiero la célula se va a cargar en cada fila por init.
P.S. Las conexiones del control deslizante y el campo de texto funcionan bien. También hice todas las conexiones IB.
CustomTableViewCell.m
#import "CustomTableViewCell.h"
@implementation CustomTableViewCell
@synthesize sliderLabel, slider;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (IBAction)getSliderValuesWithValue:(UISlider *)sender
{
sliderLabel.text = [NSString stringWithFormat:@"%i/100", (int) roundf(sender.value)];
}
@end
Further Code
- (CustomTableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Kriterium";
CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell...
cell.textLabel.text = [NSString stringWithFormat:@"%@", [listOfItems objectAtIndex:indexPath.row]];
return cell;
}
P. S. Si agrego algunos botones, etc. programáticamente en el método anterior, funciona. Pero quiero diseñar las filas en IB. Tiene que haber una solución.
¿Se puede publicar el código de su método cellForRowAtIndexPath utilizado al rellenar UITableView con filas? – reddersky
Actualicé mi respuesta. – DAS
¿Ha diseñado esta celda en una punta separada o como un prototipo dentro de la vista de tabla en el guión gráfico? – jrturton