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

How to remove bounce effect on switchToViewController #33

Closed
ghost opened this issue Apr 19, 2014 · 4 comments
Closed

How to remove bounce effect on switchToViewController #33

ghost opened this issue Apr 19, 2014 · 4 comments

Comments

@ghost
Copy link

ghost commented Apr 19, 2014

Is there anyway to remove the bounce effect upon switchToViewController? I just want my viewController to appear on switchToViewController like when closing the slide navigation menu when tapping the leftBarButton (no bounce).

@aryaxt
Copy link
Owner

aryaxt commented Apr 19, 2014

There is currently no way to do that.
I'll add it to the list of features to add.

@ghost
Copy link
Author

ghost commented Apr 19, 2014

Thanks. But for now. Can I just use the animation that was used in closing the slide menu to switchToViewController?

@aryaxt
Copy link
Owner

aryaxt commented Apr 19, 2014

Animations are for revealing the menu not the navigation controller.

Create a category for SlideNavigationController. Add the following method and use it for switching viewControllers. I just wrote this haven't done much testing on it. So make sure it works for your need. It'll be tested and added to the new release

- (void)switchToViewController:(UIViewController *)viewController withSlideOutAnimation:(BOOL)slideOutAnimation andCompletion:(void (^)())completion {
    if (self.avoidSwitchingToSameClassViewController && [self.topViewController isKindOfClass:viewController.class])
    {
        [self closeMenuWithCompletion:completion];
        return;
    }

    void (^switchAndCloseMenu)(void) = ^() {
        [super popToRootViewControllerAnimated:NO];
        [super pushViewController:viewController animated:NO];

        [self closeMenuWithCompletion:^{
            if (completion)
                completion();
        }];
    };

    if ([self isMenuOpen])
    {
        if (slideOutAnimation)
        {
            [UIView animateWithDuration:(slideOutAnimation) ? MENU_SLIDE_ANIMATION_DURATION : 0
                                  delay:0
                                options:UIViewAnimationOptionCurveEaseOut
                             animations:^{
                                 CGFloat width = self.horizontalSize;
                                 CGFloat moveLocation = (self.horizontalLocation> 0) ? width : -1*width;
                                 [self moveHorizontallyToLocation:moveLocation];
                             } completion:^(BOOL finished) {
                                 switchAndCloseMenu();
                             }];
        }
        else
        {
            switchAndCloseMenu();
        }
    }
    else
    {
        switchAndCloseMenu();
    }
}

@ghost
Copy link
Author

ghost commented Apr 19, 2014

Great! This seems to be working well. Thanks.

@aryaxt aryaxt closed this as completed Apr 30, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant