I'm having a problem with UITableView section animations very similar to this post. Unfortunately, no one seems to have found an answer for this.
I have a table view with multiple sections that expand and close when the first cell in each section is selected. There no adding or removing of cell, just collapsing and expanding the section.
My problem is that the sections' header titles are flashing white momentarily before returning to normal, whenever the following method is used.
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation: UITableViewRowAnimationAutomatic];
Only the title of the section being collapsed is flashing white though. Has anyone else had this problem or found a solution?
I'm using this same design in another table where this is not an issue. One thing to note here though, is that my cells are a custom subclass of the UITableCell and are larger than the first cell that is used to collapse the section.
Maybe something about ios laying out the cells on section animation is making the section header title flash white?
I can post a code example it it'll help.
Related
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.
Recently I have been trying to create a table view with different table view cells. What I want to do is that when users click on each table view cell, it shows an extra cell underneath the selected cell to handle user inputs and the extra section disappears when the cell is unselected.
I am fairly new to iOS development and I am wondering what would be the best way to achieve this. At the moment I am thinking of hiding the extra cells initially and displaying each of them when the cell above is selected.
Any help would be appreciated.
Apple has a great set of sample code that demonstrates the behavior you're looking for — displaying a cell beneath another cell when selected. This behavior is used in Calendar when displaying a date picker, and it's pretty much what you've described.
Question: Will each cell have an identical set of options?
If so, I'd consider including the user inputs as part of the source cell and adjusting the height of the source on selection. You can animate the cell's height changing using tableView's beginUpdates and endUpdates. This way, you avoid messing around with cell indices.
I have a UITableView that's divided into sections, some of which I'm trying to make collapsible - tap on a section's header, and the cells in the section will expand/collapse.
I'm doing this with tableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: .Automatic), inside a self.tableView.beginUpdates() and self.tableView.endUpdates() block.
When opening a section for the first time (i.e. adding rows to the section for the first time), the cells inside aren't laid out properly. Instead of multiline text and a cell whose height expands to fit the required content, I get a one-line cell that's the standard 44pts high whose text is truncated with an ellipsis.
The cells' heights are usually controlled by estimatedHeightForRowAtIndexPath returning UITableViewAutomaticDimension.
The cells seem to get re-drawn and show their correct layout when they are scrolled off screen, or when a section is closed and re-opened.
So is there a way for me to make the cell/section/table redraw itself before the new cells are animated into view?
I've unsuccessfully tried things like self.tableView.reloadData() and reloadRowsAtIndexPaths, but I may not have been using these correctly.
I think I've got the right code, but it's possibly in the wrong place in the "rendering sequence", for want of a better term.
Many thanks!
I was just having the same problem and was able to fix this by setting an estimatedRowHeight for the tableView. The default value is 0 so setting it to a positive value seems to do the trick:
tableView.estimatedRowHeight = 44.0;
self.mainTableView.beginUpdates()
self.mainTableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: UITableViewRowAnimation.Fade)
self.mainTableView.reloadRowsAtIndexPaths(self.mainTableView.indexPathsForVisibleRows!, withRowAnimation: UITableViewRowAnimation.Fade)
self.mainTableView.endUpdates()
This worked perfect for me.
I'm implementing Apple's section expanding TalbleViewSection example, which can be found here. When my section background is transparent deleting or inserting cells with UITableViewRowAnimationTop and UITableViewRowAnimationBottom causes something like this:
Probably it is not about sections, same thing will happen with UITableViewCell too. Question is, How am I going to make the row disappear before it collides with the section?
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.