Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlay breaks buttons #9

Closed
kwerle opened this issue Jan 1, 2016 · 3 comments
Closed

Overlay breaks buttons #9

kwerle opened this issue Jan 1, 2016 · 3 comments

Comments

@kwerle
Copy link
Contributor

kwerle commented Jan 1, 2016

I've added an overlay that covers the whole screen (ios):

    cameraOverlayView = myView
    cameraOverlayView.frame = self.view.frame

There are a couple of buttons on the overlay, and they work fine. But when I click on any other location on the screen, the click passes through to the focus view - bypassing the buttons (take picture, flash, reverse).

(the buttons I'm adding on on the bottom left and on the right side of the screen)

@zhangao0086
Copy link
Owner

Hi @kwerle
In the case, the cameraOverlayView will be the hit-test view always. So when you click on any other location, the touchesBegan of the DKCamera will be called. To solve this, you have to override your cameraOverlayView's hitTest method like so:

class CustomView: UIView {
    private override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
        let hitTestingView = super.hitTest(point, withEvent: event)
        return hitTestingView == self ? nil : hitTestingView
    }
}

See also: The Responder Chain

@kwerle
Copy link
Contributor Author

kwerle commented Jan 4, 2016

I recommend you rename this PassthroughView and include it in the framework. It's super handy and it's what most developers are going to want to use or subclass if they do an overlay.

@zhangao0086
Copy link
Owner

@kwerle
Thanks for your suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants