reloadSections:withRowAnimation: automatically scrolls UITableView - ios

I am using a UITableview with dynamic height rows, and in content I have "Read more" type button. On tapping the button, I append data in a row and call reloadSections:withRowAnimation: for that section.
Everything works as expected, with just one problem - that the tableview automatically scrolls to some other cell after reloadSections:withRowAnimation:. Can anyone help me to find out why it is happening ?

Related

UITableView - Expand and Collapsible section issue

I have 15 sections with dynamic height sections and rows. By default all sections are closed. After scrolling to end of tableview, I am tapping on last section and it opens properly but when I click again to close section at that time my tableview scroll to top.
This issue occurs when some of the sections are scrolled and after that when click on any visible section.
Please anyone knows what exactly the issue.

UITableView beginUpdate and endUpdate on last cell reloads tableview

I have a tableview with expand-collapse cells. Whenever a cell is selected, I simply call :
tableView.beginUpdate()
tableView.endUpdate()
This in turns recalls the heightForRowAtIndex method, where I set the new height and this seems to show expand-collapse behavior.(without reloading the cell).
ISSUE: When I tap on last cell(or last 2-3 cells), after tableView.beginUpdate()
tableView.endUpdate(), the table reloads itself. I have no clue why it is behaving like this.
It seams like since there is no space at the table's bottom to expand a cell, it's reloading itself.
Can someone throw light on this?
estimatedHeightForRowAt works always.

IOS Table View + TextView in a UITableView Cell

I have a static table view with 3 sections and a row in each section.
For each row, I have it setup to be 150 talk in the heightForRowAtIndexPath.
Then on a tap of the row, I have it setup to expand to the height of the device.
All of that works great.
In the expanded row is a textView. When the user selects the textview, the keyboard pops up and pushes the top of the row off screen for a second and then the tableview seems to catch itself and bring it back down to be visible. How can I make sure that it doesnt do that because it looks buggy from the users POV.

Swift expandable tableview

I am using an expandable tableview in swift. Suppose there are three rows in the tableview. Each row has on one view for their expandable. Now I expand the 2nd row, and reload either the full tableview or the particular 2nd row. In that case the expanded view get collapsed. But I want that the expanded cell doesn't get collapsed. So, is there any suggestion how can I stop collapsing the cell after reload?
the best way would be to post an issue to the github repository, I believe the original developer can fix it.

Making section in UITableView closed(with 0 cells) after scrolling away and returning to it

I have a UITableView where I have section headers that can be tapped to expand or collapse the section. In my particular example each section only has one row, which is either visible (section expanded) or hidden (section collapsed). (I have a UITapGestureRecognizer on the section headers which I use to expand or collapse the sections) here the process of my actions:
I'm tap on the section (this is UITableViewHeaderFooterView custom view) and i see the cell that appears under the section header. At this moment everything is going OK. But when i scrolling down my tableview, cell goes behind header (like in Contacts application , header is first letter of contact). And finally when i scroll enough to don't see that section with that cell on, and when i scroll up - to return to my display that section - i want to make this section automatically known that when i return(from scrolling away that section from view) to it - i want that section already was closed with 0 cells in it.
Maybe i must use -(void) prepareForReuse at my custom UITableViewHeaderFooterView, or scroll methods ? or any tableView methods?
Thank you
You can implement the scroll view delegate methods and use them to check the scroll position (contentOffset) and / or the visible cells (indexPathsForVisibleRows). Once you know that you can collapse any sections that are no longer visible. You should probably use one of the scroll methods that means the scrolling has stopped (maybe scrollViewDidEndScrollingAnimation:) because changing the table view content size (which changing the number of rows will do) during a scroll animation could cause it to stop abruptly.

Resources