Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Shaun Johnson1,214 Points
Adding row to *bottom* of TableView
Disclaimer: relatively new to iOS.
I have a TableView with an add row capability.
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.
I 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.