Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialShaun Johnson
1,214 PointsAdding row to *bottom* of TableView
Disclaimer: relatively new to iOS.
I have a TableView with an add row capability.
My code:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow: 0 inSection: 0];
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation: UITableViewRowAnimationBottom];
I would like the indexPathForRow to be such that the new element is inserted at the bottom, not the top.
Thanks,
Shaun
1 Answer
kerdeseverin
9,688 PointsI think it might be easier to add the value to the array which your table uses for data. Add to the array and reload the table or cells. It will show up at the bottom because your value value was added to the last position in the array and your cellForRow index will take care of the rest.