当我在表中选择一行时,我需要在表视图中添加新行。
我应该使用以下方法吗?
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
我应该在方法中写什么来添加新行?
请帮助我,
提前致谢
世宾。
当我动态添加行时,我使用 insertRowsAtIndexPaths: 这是一个示例函数
- (void) allServersFound {
// called from delegate when bonjourservices has listings of machines:
bonjourMachines = [bonjourService foundServers]; // NSArray of machine names;
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
int i = 0;
for (NSArray *count in bonjourMachines) {
[tempArray addObject:[NSIndexPath indexPathForRow:i++ inSection:0]];
}
[[self tableView] beginUpdates];
[[self tableView] insertRowsAtIndexPaths:(NSArray *)tempArray withRowAnimation:UITableViewRowAnimationNone];
[[self tableView] endUpdates];
[tempArray release];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)