He leído el artículo de Loren sobre cómo dibujar tu propio contenido para UITableViewCell. Sin embargo, está utilizando un método en desuso: initWithFrame:reuseIdentifier:
está en desuso en UITableViewCell.
¿Cómo consigues que su ejemplo funcione sin usar initWithFrame:reuseIdentifier
?
solo tenía que replace initWithFrame:reuseIdentifier:
con lo siguiente.
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { // you might want to add the UIView to [self contentView] // so that in edit's the cell's content will be automatically adjusted. ABTableViewCellView *myUIView = [[ABTableViewCellView alloc] initWithFrame:CGRectZero]; myUIView.opaque = YES; contentViewForCell = myUIView; [self addSubview:myUIView]; [myUIView release]; } return self; }
Además, Apple tiene un ejemplo como señala Loren, pero usan initWithStyle:reuseIdentifier:
http://developer.apple.com/iphone/library/samplecode/TableViewSuite/Introduction/Intro.html
Puede consultar este enlace para encontrar el reemploop del método en desuso. Debería ser bastante fácil get el código trabajando con el reemploop. http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableViewCell_Class/DeprecationAppendix/AppendixADeprecatedAPI.html
Otra forma específica de comprender es : initWithFrame: reuseIdentifier: está en desuso en iOS 3.0. Use initWithStyle: reuseIdentifier : en su lugar
Ejemplo simple: código de error
static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; }
Código esperado
static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier]; }