Iphone 如何将行插入UITableView?
我想使用insertRowsAtIndexPaths方法向UITableView插入一行,但我不知道如何为此方法创建“indexPaths”属性Iphone 如何将行插入UITableView?,iphone,cocoa-touch,Iphone,Cocoa Touch,我想使用insertRowsAtIndexPaths方法向UITableView插入一行,但我不知道如何为此方法创建“indexPaths”属性 请帮帮我 您可以使用 + (NSIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section; // defined in UITableView.h 创建和填充indexPaths参数的代码可能如下所示: NSMutableArray* indexPaths =
请帮帮我 您可以使用
+ (NSIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section; // defined in UITableView.h
创建和填充indexPaths参数的代码可能如下所示:
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];
}