Strange tableView row/section animation when row is selected
<p>This cool <a href="https://github.com/appcoda/expandable-table-view" rel="nofollow noreferrer" title="expanding tableView">expanding tableView</a> works great but when you select some of the rows, a weird animation occurs. </p>

<p>The table has multiple sections, and each row can show additional rows when clicked. Row appearance and behavior is structured in a plist using various values e.g. if a row's boolean "isExpandable" property in the plist is set to true and its "additionalRows" property is set to 2, the row can expand to show 2 sub-rows.</p>

<p>The issue with the table is that when the first cell in each section is clicked, the animation runs fine, but when other cells are clicked, they shuffle:-</p>

<p><a href="https://i.stack.imgur.com/s6N45.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s6N45.gif" alt="enter image description here"></a></p>

<p>I suspect the strange animation happens because all sections are reloaded when a cell is clicked because of this line under didSelectRowAtIndexPath in the ViewController file:-</p>

<pre><code>    tbl.reloadSections(NSIndexSet(index: indexPath.section), withRowAnimation: .Automatic)
</code></pre>

<p>I've tried the following but they either crash the app or cause the cells to not expand:-</p>

<ul>
<li>Setting the animation method to .None</li>
<li>Using reloadData instead</li>
<li>Storing the indexPaths of the selectedRow and its sub-rows, and then reloading all with reloadIndexPaths</li>
<li>Storing the rows of the selected cell and its subcells then reloading them once when a row is clicked</li>
</ul>

<p>Someone on the actual site that the code is posted on suggested using insertRowsAtIndexPath and deleteRowsAtIndexPath instead of reloadSection, but I'm not sure how to do it. Your help is greatly appreciated.</p>

<p><strong>EDIT</strong>
 - Also tried insertRowsAtIndexPath and deleteRowsAtIndexPath but it seems to conflict with the way the tableView model is set up and the app crashes. </p>