Kodeco Forums

Video Tutorial: Table Views in iOS Part 5: Inserting Rows

Learn how to add the ability for you user to insert rows within a table view.


This is a companion discussion topic for the original entry at http://www.raywenderlich.com/119648/video-tutorial-table-views-in-ios-part-5-inserting-rows

Note that because of the segue to the detail controller, the very last thing demonstrated doesn’t really work. When you click on the Add Icons row, a new row inserts, but you immediately segue to the detail view (not yet implemented, but hooked up in the storyboard). The “Finished” zip file has the same problem.

Can we have more video tutorials on how to dynamically add/remove rows from table.

Can we also have some tutorials on how to load more records when user scrolls to end of the table

There has a bug when i swipe left ,then it crash

2016-07-22 16:12:30.216 ScaryBugs[7941:432883] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:],

Hey man,

I spent ages trying to figure this out myself as well. Simple solution is make sure your main class is simply inheriting from UIViewController and that your extension is conforming to UITableViewDataSource and, more importantly, the UITableViewDelegate.

Once you add the delegate conformance it should stop the error you mentioned as I was getting the exact same issue.

Happy coding!

I am getting an error when I swipe to delete instead of tapping the edit button.

It seems that the extra row we add for inserting a row gets added when you swipe to delete. However when you tap to delete the cell it does not disappear causing an “Assertion failure” error to happen when you try to modify or delete another row.

Is there a way to not add the insert row when a user simply swipes to delete instead of entering edit mode via the edit button?

Thanks!

I really like the way you add cells. Its very similar to have the Apple Music App does it. Is it possible to put the add button at the top of the table like Apple Music. In cellForRowAt in the ifEditing state I tried setting the index to 0 and that didnt work. Im newbie any tips you could give me would be appreciated. Also Im using Swift 3 and my App only has one section.

I know that you noticed this bug little time ago, but I think that I found solution. You only have to override willBeginEditingRowAt and didEndEditingRowAt methods. Everything is described [here] (ios - Detect the difference between a swipe-to-delete button and a delete button made in Edit mode? - Stack Overflow). There is also interesting thing that setEditing method doesn’t fire up when you override these methods so you don’t even need special variable as it is shown in linked article.