Alua-Kinzhebayeva / iOS-PDF-Reader

PDF Reader for iOS written in Swift
MIT License
533 stars 150 forks source link

Flicker in UIPageViewController's views #27

Closed rv-17 closed 7 years ago

rv-17 commented 7 years ago

Hi,

I've integrated the PDFPageView into a UIPageViewController's view so that I can use a page controller instead of a collection view.

However, the screen flickers if it is being initially rendered. This behaviour is not present in a collection view. Scroll mode is worse than page curl.

Do I have to set any properties on the view, which hosts the PDFPageView? I don't use Storyboards.

ranunez commented 7 years ago

Hmm, nothing initially jumps out at me. Do you have a simple example repo of a PDFPageView in a UIPageViewController? PDFPageView is an internal class and wasn't intended to be used outside of the context of the framework.

rv-17 commented 7 years ago

I'll create a sample project. I use a similar implementation, so I swapped classes and got the same result.

BTW, has this issue in CoreGraphics been resolved meanwhile?

class PdfTiledLayer: CATiledLayer {
    override class func fadeDuration() -> CFTimeInterval {
        return 0.001 // Workaround
    }

    override func display() {
        //contents = nil  --> Stops flickering but causes blinking instead.
        super.display()
    }
}
rv-17 commented 7 years ago

I could pin down the part that's responsible for the issue mentioned above. It's this line:

contentScaleFactor = 1

Commenting out …

// contentScaleFactor = 1

… solves it. What's the implication not setting this property to one? Everything renders fine and quite fast now!

ranunez commented 7 years ago

https://github.com/Alua-Kinzhebayeva/iOS-PDF-Reader/blob/master/Sources/Classes/PDFPageView.swift#L132

ranunez commented 7 years ago

But having said that, if the commenting out the above code works for you in your implementation, then go for it!