IOS last tableViewCell separator is missing - ios

I have tableView with multiple cells (without sections).
I add non-empty tableFooterView to the tableView. After that the last cell separator is not shown. Also when tableView is scrolled, separator sometimes appears or disappears. It happens both on simulator and on the device.
I've checked Debug view hierarchy and found the following:
It is very strange. Penultimate cell separator is duplicated there but the last separator is single. May be the problem is somewhere there?
I've also checked it's properties:
All I found as solution is to add empty tableFooterView but I need it to be filled.
How to make the last separator be always visible (also when scrolling)?
I know you can get away without using actual separators, but adding one pixel line in the bottom of the cell. But I'm not a fan of this approach.

Related

UITableViewController with static cells: invisible cells when keyboard shows

I am using a UITableViewController with static cells, as a user details form. Everything works, until I tap in one of the cells's text field, the keyboard (or custom inputView) shows up, and you scroll the table down. Cells are then not shown, instead a blank space is shown. Scrolling up and back down then correctly shows them.
If I scroll the tableview down until the "geboortedatum" field shows up,
and press on that textfield, a custom inputView with a date picker shows up:
Now, if I scroll the tableview down, the next rows show up blank:
Two rows are supposed to show up there, like this:
It's not related to the inputView with the date picker, the same happens when the plain old keyboard shows up and you scroll the table down.
I have not overridden any of the tableview delegate or datasource methods apart from showing custom headers (but the problem is the same when I remove that), and am not using UITableViewCell subclasses, just static cells in a storyboard. It seems like an iOS bug to me, but is there any way to work around this?
I think I found the cause and the solution. The problem is that these last 2 cells don't actually fit in the storyboard design:
They are there of course, just not visible by default. If I change the storyboard to freeform with a custom height to make it all fit, like this:
Then the problem doesn't show up anymore. The cells are not hidden anymore on scroll, as before. Very strange.

UITableView cells disappearing, wrong cell passed to didEndDisplayingCell

I'm seeing another case of UITableView cells disappearing unexpectedly when scrolling, but none of the similar questions & answers here I've seen really fit what I'm seeing:
I scroll down until my top cell is removed and tableView:didEndDisplayingCell:forRowAtIndexPath: is called for it, then scroll back up until it's shown again. During the scroll up, the tableview is trying to remove the cells that were shown while scrolling down, however its actually removing the wrong cells.
As I'm scrolling up, tableView:didEndDisplayingCell:forRowAtIndexPath: is getting called with the correct index path, one it should be removing, but a cell that corresponds to a different index path. The cell and index path passed to the didEndDisplayingCell don't match.
This is in a small modification of the XLForm example project from https://github.com/xmartlabs/XLForm in which I've added a custom cell. What's weird is that if I make my custom cell the same height as the table's normal height (44) then this doesn't happen. Only when my cell is taller (64, with this value returned from tableView:heightForRowAtIndexPath: and tableView:estimatedHeightForRowAtIndexPath:).
I'm seeing this happen when running in the simulator, iOS versions 8.4 and 9.2.
I haven't been able to figure this out. I don't think I have any of the bugs that have caused others to have disappearing cell syndrome, but even if I do, I don't see how or why the tableview would be calling didEndDisplayingCell with cell and index path that don't match. Does anyone else have a clue what's happening?

UITableView cells are unloaded too early after reordering

I've recently built in reordering into my UITableView but there's a nasty bug I'm experiencing after reordering the cells. The bug only occurs after a cell has been reordered: When scrolling the table view up, the cells visible at the bottom of the screen sometimes simply disappear while scrolling. It seems as if the cells are unloaded too early. This only happens when scrolling up. When scrolling down the bug doesn't exist. The cells that randomly disappear also re-appear when scrolling down once their empty space leaves the screen. Here's a screenshot of this issue:
I'm pretty sure that my data source isn't the problem because:
When reordering a cell my data source updates as well
I've checked the table view with Spark Inspector and the missing cells aren't simply hidden or empty but they just don't exist, there is no cell at all where the empty spaces are.
After scrolling around the cells re-appear, the cells randomly appear and disappear
It must be some bug or issue in UITableView, but I may also be wrong with that assumption. Maybe somebody has already faced this problem and can help me out now ;) I'm waiting for your answers :)
Edit:
I just checked the -tableView:didEndDisplayingCell:forRowAtIndexPath: delegate method and the cells are really unloaded normally and that method is called, even though the cells are still visible on the screen!
Edit (2):
I now know that the issue only occurs when my table view has a header view. It doesn't matter if I use the default header or a custom one, but whenever I use a header view I also get the bug. When I don't use a header it works just fine. Thats really strange
Note: I'm testing this on iOS 6.1.2

Issues regarding dynamic resizing of label and row heights (iOS)

Context:
Building an app that populates a table that takes in data from a asyc json dump.
The cells are of a custom class (I defined). The main label in the cell can be very long.
It is "placed" in storyboard within a prototype cell but customized via code (pretty standard stuff).
Labels are resized in cellForRowAtIndexPath and rows are resized via heightForRowAtIndexPath -- rows are resized by forcing a call to cellForRowAtIndex like Massimo's answer here
So per the question at hand - I've noticed some interesting (bad) things that happen.
First issue: When the table loads, the rows and labels are dynamically resized correctly! Great! However, when I scroll down and then scroll back up, the label heights will be incorrect -- (for example) the first row was correct at loading. Then when I scroll down and then scroll back up to see it again, it will be truncated. Specifically, the row size will be fine but the label height will change and become truncated to 2 lines only. Wondering if this is because I did both storyboard and coding to customize the cell. Anybody see this before?
Second issue: When I scroll down, while the rows are sized correctly (large), the labels are short (truncated.) Wondering if it's some reverse of the above "potential answer".
"potential answer" is that the rows are all calculated and stored "up front" so that scrolling down/then back up doesn't affect it. However, when cells go "out of view" and are dequeued then when they re-viewed (scroll down/then back up) it will rely on the storyboard.(inappropriately?)
All three of your issues are symptomatic of returning the wrong height in heightForRowAtIndexPath. In my data model classes I have a calculateHeight method that I call in heightForRowAtIndexPath. The model also caches the answer so it doesn't have to recalculate it after the first call. The cell class uses the model's calculated height to layout its subviews.
"ANSWERED" by deleting the prototype cell from the storyboard and making them fully in code, the issue went away. The fundamental workings are still not understood (ie. the interactions between storyboard vs. code when cells are put queued and then viewed again)

don't want the last UITableViewCell's height used as the height for the subsequent blank cells

I have a table view. When a cell is tap, it animates it's expansion to show other options. Actually, this is what I've made. The problem is that if the last cell is tapped, all the subsequent (blank) cells assume the height of the last cell. I don't want this to happen. It's ugly and frankly makes no sense. I tried adding a conditional in the heightForRowAtIndexPath. This does not work. I'd prefer not a hack, but if you find something concrete like creating an invisible cell at the end or something, let me know. I'm searching currently,

Resources