corin8823 / Popover

Popover is a balloon library like Facebook app. It is written in pure swift.
MIT License
2.09k stars 326 forks source link

Popover with AutoLayout? #102

Open lpbas opened 6 years ago

lpbas commented 6 years ago

Hello. I'm using this awesome library to show quick pop ups in my app where the user takes a small action. However, on rotation, the popup does not stay in place, so I would like to use AutoLayout to keep it in place.

Whenever I try though, the pop either disappears or one of its corners gets entered in the screen.

Is there a way to fully manage the popup via auto layout? Thank you very much!

alexsteinerde commented 5 years ago

Is their any progress to supporting device rotation in some way?

lpbas commented 5 years ago

I don't know if the dev is looking into the problem. For the moment, I'm dismissing the popover in viewWillTransitionToSize: and showing it again when the rotation finishes like this:

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)

    // Will execute before rotation
    var shouldShowNote = false
    if notePopover != nil {
        shouldShowNote = true
        notePopover?.dismiss()
    }

    coordinator.animate(alongsideTransition: {(_ context: Any) -> Void in
        // Will execute during rotation
    }, completion: {(_ context: Any) -> Void in
        // Will execute after rotation
        if shouldShowNote {
            self.noteTapped(nil)
        }
    })
}

where noteTapped() presents my popover. Keep your popover into a local property. It looks semi-ok, with the animations, but it would be great if the library handled rotation properly...