Tengo un TableView que crea y dibuja bien, pero luego se bloquea al desplazarse por la vista. He corrido a través del depurador y parece que mis variables de nivel de clase se sobrescriben de alguna manera, por lo que ya no existen cuando se llama de nuevo titleForHeaderInSection. Lo extraño es que si puedo reemplazar el código:UITableView se bloquea en el desplazamiento
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = [favouritesDataSections objectAtIndex:section];
return sectionTitle;
}
con:
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = @"Test";
return sectionTitle;
}
Se vuelve a colgarse, pero esta vez las listas depurador no un NSString cuando se pasa sobre la variable sectionTitle.
Este es el código que utilicé para crear la vista y establecer las variables de nivel de clase:
- (void)loadView {
[super loadView];
CGRect tableSize = CGRectMake(0,0,320,460);
UITableView *favouritesTableView = [[UITableView alloc] initWithFrame:tableSize style:UITableViewStylePlain];
favouritesTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
favouritesTableView.dataSource = self;
favouritesTableView.delegate = self;
favouritesTableView.rowHeight = 52;
[self.view addSubview:favouritesTableView];
}
- (void)viewDidLoad {
[super viewDidLoad];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// Get the full path of the favourites plist
NSString *filename = [documentsDirectory stringByAppendingPathComponent:@"Favourites.plist"];
// Initialise Dictionary and array
favouritesDataAll = [[NSMutableDictionary alloc] init];
favouritesDataSections = [[NSArray alloc] init];
NSDictionary *dict = [[[NSMutableDictionary alloc] initWithContentsOfFile:filename] retain];
favouritesDataAll = dict;
[dict release];
favouritesDataSections = [favouritesDataAll allKeys];
}
voy absolutamente loco tratando de localizar esto abajo - de pasar 2 días en él hasta ahora tan sería externamente agradecido por cualquier ayuda.
Saludos
de Dave
bien, si pongo en retienen al final de la línea UITableView funciona durante unos 3 o cuatro veces y luego la consola da: *** - [longitud UISwipeGestureRecognizer]: Selector no reconocido enviado a la instancia 0x43325d0 –
y también: *** Aplicación de terminación debido a la excepción no detectada 'NSRangeException', razón: '*** - [NSCFArray objectAtIndex:]: índice (0) más allá de los límites (0)' –
OK, me callaré. La retencion era I arenque rojo, creo. Fue porque reemplacé el titleForHeaderInSection por @ "Test" funcionó por un tiempo. El error de la consola es: *** Aplicación de finalización debido a la excepción no detectada 'NSRangeException', razón: '*** - [NSCFArray objectAtIndex:]: índice (57744) más allá de los límites (2)' –