J'ai une vue de table indexée qui organise les villes dans un état par leur première lettre. Ce que je travaille est un NSMutableDictionary est créé avec les clés de A, B, C, etc. et les villes correspondantes sont ajoutées à leurs tableaux respectifs. ex:UITableView Indexation
Y = (
Yatesboro,
Yeagertown,
York,
"York Haven",
"York New Salem",
"York Springs",
Youngstown,
Youngsville,
Youngwood,
Yukon
);
Z = (
Zelienople,
Zieglerville,
"Zion Grove",
Zionhill,
Zionsville,
Zullinger
);
maintenant, mon point de vue de la table des charges avec le nombre correct de sections et les lignes dans les sections et le contrôle d'indexation fonctionne très bien avec ceci:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [cities count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if([searchArray count]==0)
return @"";
return [searchArray objectAtIndex:section];
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[cities objectForKey:[searchArray objectAtIndex:section]] count];
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
NSLog([NSString stringWithFormat:@"clicked index : %i",index]);
if (index == 0) {
[tableView scrollRectToVisible:[[tableView tableHeaderView] bounds] animated:NO];
return -1;
}
return index;
}
Mon problème peuplait maintenant le texte de la cellule de table avec le texte pour chaque section ... Des pensées sur comment je peux saisir cette information?
A travaillé comme un homme de charme. Sauvé un mal de tête majeur pour moi. Merci! – rson