在iphone的TableView中动态添加一行 [英] Add a row dynamically in TableView of iphone

查看:105
本文介绍了在iphone的TableView中动态添加一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在表格中选择一行时,我需要在tableview中添加一个新行。

I need to add a new row in the tableview when i select a row in the table.

我想使用以下方法吗?

- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation

我在方法中写了什么以添加新行。?

What shoud i write inside the method to add a new row.?

请做帮助我,

提前谢谢
Shibin。

Thanks in advance Shibin.

推荐答案

当我动态添加一行时,我使用insertRowsAtIndexPaths:这是一个示例函数

When I add a row dynamically, I use insertRowsAtIndexPaths: here is an example function

- (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];
}

这篇关于在iphone的TableView中动态添加一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆