matthewcheok / MCPanelViewController

Drop-in panel control for iOS with blurring background and screen-edge activation gestures.
MIT License
324 stars 25 forks source link

UIPanGestureRecognizer and manually presenting panel #12

Closed yongeli closed 10 years ago

yongeli commented 10 years ago

Hi,

I'm trying to present the side panel onto screen with a pan gesture of left/right, as opposed to just the edge pan gestures.

Whenever I try to present the view manually with a pan gesture like so:

[self.tabBarController presentPanelViewController:tintedPanelViewController withDirection:MCPanelAnimationDirectionLeft];

the panel would flicker a few times (recreating itself over and over?) then present itself into view.

Any ideas what would be causing this?

Thank you for the project and thanks for any help on this.

matthewcheok commented 10 years ago

Do you have a sample project I can take a look at?

On Tue, Jul 22, 2014 at 10:16 AM, Yonge Li notifications@github.com wrote:

Hi, I'm trying to present the side panel onto screen with a pan gesture of left/right, as opposed to just the edge pan gestures. Whenever I try to present the view manually with a pan gesture like so: [self.tabBarController presentPanelViewController:tintedPanelViewController withDirection:MCPanelAnimationDirectionLeft]; the panel would flicker a few times (recreating itself over and over?) then present itself into view. Any ideas what would be causing this?

Thank you for the project and thanks for any help on this.

Reply to this email directly or view it on GitHub: https://github.com/matthewcheok/MCPanelViewController/issues/12

yongeli commented 10 years ago

Thanks for the really quick reply, I've made a sample project hopefully to demonstrate what I mean

https://github.com/Sxcerino/sample

Thank you

matthewcheok commented 10 years ago

Hey this is not really a issue with MCPanelViewController. UIPanGestureRecognizer is a continuous gesture recogniser and calls its selector many times.

This should fix this issue:

- (void)panGestureRecognized:(UIPanGestureRecognizer *)pan
{
    // Dismiss keyboard (optional)
    //
    switch (pan.state) {
        case UIGestureRecognizerStateBegan:
            [self.view endEditing:YES];
            [self.tabBarController presentPanelViewController:tintedPanelViewController withDirection:MCPanelAnimationDirectionLeft];
            break;

        case UIGestureRecognizerStateChanged:
            break;

        case UIGestureRecognizerStateEnded:
        case UIGestureRecognizerStateCancelled:
           break;

        default:
            break;
    }
}
yongeli commented 10 years ago

My mistake! Thanks a lot for your help.

Although One last question however - would it be possible to still animate the dynamic effect from edge pan dragging into the general gesture recognizer? or if there is anyway really quickly to modify the edge pan to gesture pan?

Thanks again, much appreciated.