Alua-Kinzhebayeva / iOS-PDF-Reader

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

Double Tap opens/closes NavigationBar #35

Closed nidomiro closed 7 years ago

nidomiro commented 7 years ago

In the current (podfile) version a double tap also opens/closes the NavigationBar. To ignore the single tap if there is a double tap I altered your code the following way:

Inside PDFPageView.swift:

internal final class PDFPageView: UIScrollView {

    ...

    init(frame: CGRect, document: PDFDocument, pageNumber: Int, pageViewDelegate: PDFPageViewDelegate?) {

        ...

        let doubleTapOne = UITapGestureRecognizer(target: self, action:#selector(handleDoubleTap))
        doubleTapOne.numberOfTapsRequired = 2
        doubleTapOne.cancelsTouchesInView = false
        addGestureRecognizer(doubleTapOne)

        let singleTapOne = UITapGestureRecognizer(target: self, action:#selector(handleSingleTap))
        singleTapOne.numberOfTapsRequired = 1
        singleTapOne.cancelsTouchesInView = false
        addGestureRecognizer(singleTapOne)

        singleTapOne.require(toFail: doubleTapOne) // New Line

        ...
    }    
    ...
}

feel free to adopt this behaviour ;)

ranunez commented 7 years ago

Thanks! Single tapping toggles the nav bar, and initially I assumed double tapping, in addition to zooming in and out of the document, should also toggle the nav bar, but now I'm having my doubts whether this is the right approach. I think we should keep it simple: single tap to toggle the nav bar, double tap to zoom in and out. Feel free to open a pull request if you're interested in getting credit for the commit :) I'll also leave this issue open a while longer in case anybody has any strong opinions one way or another.

nidomiro commented 7 years ago

Thanks, but it would be nice, if you could change that. A Fork for this little line is overkill in my opinion ;)