Lukas Kalinski
Lukas Kalinski

Reputation: 2243

UICollectionView flickers thin "see through" lines between cells when scrolling

I have a UICollectionView with cells that are filled with a background image. The collection view has line spacing = 0.

This has been working perfectly well on iOS 6.1, but when tested on the iPhone 6 with iOS 8.1.3 I see thin "see through" lines appearing spontaneously between cells on collection view load, and then they are jumping around when scrolling.

So, how do I get rid of these lines?

Upvotes: 3

Views: 1604

Answers (4)

scrrr
scrrr

Reputation: 5340

Check if the width and height of your collection view is an exact multiple of the widths and heights of your cells.

Upvotes: 0

john1034
john1034

Reputation: 128

I had the same problem, but it also happened on iPhone 4 with iOS7 (not only on iPhone 6 with iOS8.1). "See through" lines appeared between my section header and between the cells, some of them were permanent, others could just blink or disappear when I scrolled the view.

I could solve it expanding the background of my section header and cells by two pixels (in the bottom) and setting both views to not clip its subviews, as Lukas Kalinski suggested. Disabling clipping alone didn't work.

This worked for me, but it's kind of a hack. Not sure why iOS is presenting this behavior. I feel like we're still missing something.

I didn't try the suggested answer because I need to support iOS6+ and I can't stop using the iPhone 6 scale mode.

Upvotes: 1

Adama
Adama

Reputation: 1097

EDIT* - This is actually caused by the app's deployment target being set as iOS7. When I switch to ios8, the problem goes away.

Sounds like you need to update your app to properly support iPhone 6/6+ screen sizes. One of my apps has this problem.

You'll need to go to your project settings and set a launch screen file so that it knows to show your app at actual size on the iphone 6/6+; otherwise, it will just show a scaled view of what one sees on the iPhone 5s.

I'm assuming this happens because the scaling from iphone5 to 6/6+ isn't exactly 1:1 pixel ratio. For example, because of imperfect scaling, a line at y:50 might be 1 pixel tall, but at y:51 it might be 2 pixels tall, which when scrolling causes a noticeable flicker.

Upvotes: 1

Lukas Kalinski
Lukas Kalinski

Reputation: 2243

I found a solution: make sure that all cells have "Clip subviews" unchecked. I guess this must be a bug, as the solution doesn't make sense, but it solved the problem.

Upvotes: 4

Related Questions