【问题标题】:How to show last added data in table without reload it?如何在不重新加载的情况下在表中显示最后添加的数据?
【发布时间】:2012-09-21 09:41:12
【问题描述】:

我有一个 tableview,在 viewDidLoad 时有 20 行。现在我有一个按钮可以在表格中再添加 1 行数据。此时我不想重新加载表格并希望显示最后一行的更新表格。是否可以?如果是,请帮助我。 谢谢。

【问题讨论】:

    标签: iphone objective-c xcode uitableview tablecell


    【解决方案1】:

    你可以这样做

    [tableView beginUpdates];
    [self.table insertRowsAtIndexPaths:path withRowAnimation:UITableViewRowAnimationRight];
    [tableView endUpdates];
    

    【讨论】:

    • 感谢您的回复。但是你能告诉我将在哪个表委托方法上添加这段代码吗?
    • 您可以在想要添加新行的任何时间调用它
    • 好的,我正在从 connectionDidFinishLoading 方法中添加新行。首先我从这里重新加载我的表,但是如果我通过你的代码[replace reload table1],那么我将如何获得路径的值。
    • NSIndexPath *path=[NSIndexPath indexPathForRow:your_row inSection:your_section];
    • 感谢您的支持,但在 connectionDidFinishLoading 中,我将如何获得 your_row 和 your_section。请提供一个合适的地方让我可以使用你的代码。
    猜你喜欢
    • 2016-07-09
    • 1970-01-01
    • 1970-01-01
    • 2017-06-27
    • 1970-01-01
    • 1970-01-01
    • 2017-01-24
    • 1970-01-01
    • 2016-12-26
    相关资源
    最近更新 更多