-2

I have a tableview set up that i can drill down about 3 levels. I have an edit button at the top that lets me delete rows. I've just used a mutable array to store data and I can remove items from the array. This all works fine.

For the life of me I can't figure out how to add a row. I've been through all the documentation but can't get it working. I've tried countless things.

I've edited numberOfRowsInSection so that in editing mode it is incremented by 1. But I don't know how to make that row appear. I want an extra row at the bottom (in editing mode) so that I can add a row. I just don't know how to get that row on the screen.

If someone has code for a simple tableview, just one view, that has an edit button that allows for adding and deleting a row I'd really appreciate it. Just can't get my head around something here.

Cheers. Stephen

4

1 回答 1

0

您可以将新项目添加到数组并调用[UITableView reloadData].

或者您可以使用:

[tableView beginUpdate];
[tableView insertRowsAtIndexPaths:*arrayOfIndexPaths* withRowAnimation:*rowAnimation*];
[tableView endUpdate];
于 2012-09-10T15:48:02.617 回答