Je veux utiliser la méthode insertRowsAtIndexPaths pour insérer une ligne dans UITableView, mais je ne sais pas comment faire de la propriété "indexPaths" pour cette méthode.Comment insérer une ligne dans UITableView?
Aidez-moi s'il vous plaît!
Je veux utiliser la méthode insertRowsAtIndexPaths pour insérer une ligne dans UITableView, mais je ne sais pas comment faire de la propriété "indexPaths" pour cette méthode.Comment insérer une ligne dans UITableView?
Aidez-moi s'il vous plaît!
Vous pouvez créer NSIndexPath unique à l'aide
+ (NSIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section; // defined in UITableView.h
Votre code pour créer et remplir indexPaths paramater peut ressembler à:
NSMutableArray* indexPaths = [NSMutableArray arrayWithCapacity:10];
for (...) // iterate to get all indexes and section you need
{
[indexPaths addObject:[NSIndexPath indexPathForRow:someRow inSection:someSection]];
}
//indexPaths is ready to use
- (NSIndexPath *) indexPathForRow:(NSUInteger)row andSection:(NSUInteger)section {
NSUInteger _path[2] = {section, row};
NSIndexPath *_indexPath = [[NSIndexPath alloc] initWithIndexes:_path length:2];
return [_indexPath autorelease];
}
Alex, merci pour votre aide! – hungbm06
Il est utile! Merci beaucoup, Vladimir – hungbm06