Search code examples
iosswiftuitableviewios9xcode7

TableView Cells Overlapping UIView After Scrolling Down and Up


I'm playing around with some design concepts and I got stuck with this "bug."

Any idea why is this happening? I've iterated through different things and still can't find the culprit or solution to this.

This "circle" for the price, overlapping the other cell at the bottom of it is my intended design. This is all good, however, when I scroll down and back up, "older" cells suddenly overlaps the "circle."

Kindly see the screenshot. Any help is much appreciated!!!

Has anyone experienced this before?

iOS9 - Xcode 7.3.1

EDIT:

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    if let cell = tableView.dequeueReusableCellWithIdentifier("CategoryCell") as? CategoryCell {

        cell.selectionStyle = .None
        cell.configureCell(dishes[indexPath.row])

        return cell

    } else {
        return UITableViewCell()
    }

}

Mobile Screenshot

EDIT 2: After further analysis, I am quite convinced that this has nothing to do with the height? I played around using different heights but still get the same results.

The thing is, it loads perfectly, even when scrolling down, it's all good. Up until I scroll back up, that's where the problem starts to appear.

Setting the Clip SubViews (Cell) to true will clip everything even on load, so I've set it to false.

The remaining question is, how to handle the clipping when scrolling back up?

StoryBoard

EDIT 3: I think I now understand the problem however, I am still not quite sure how to solve it.

The CircleView is placed on a cell that is meant to overlap to the other cell below it. Settings clipsToBounds, height or putting it infront will have no effect to the cell below it as it goes away from the display when scrolled up.

Anybody has an idea how to somehow redraw this just like it has been freshly loaded (because onload, things are working)? or perhaps is there a clipsToBounds setting elsewhere that I am missing?

I think the solution relates to this: How to stop UITableView from clipping UITableViewCell contents in iOS 7

However, this solution is not working on ios9.


Solution

  • Set the cell layer anchorPointZ to row index in cellForRowAtIndexPath: method

    cell.layer.anchorPointZ = indexPath.row;