rnystrom / RNFrostedSidebar

A Control Center-esque control with blurred background and toggle animations.
MIT License
2.12k stars 340 forks source link

Behave in navigationController #19

Closed mrodalgaard closed 10 years ago

mrodalgaard commented 11 years ago

As a solution to the subject discussed in Issue #8, where RNFrostedSidebar is used to push a new viewController in a navigationController.

Show the sidebar on top of the navigationController:

    RNFrostedSidebar *callout = [[RNFrostedSidebar alloc] initWithImages:images];
    callout.delegate = self;
    [callout show];

In didTapItemAtIndex call dismissInNavigation before sergue to correctly remove the sidebar from the parentViewController before pushing the new viewController, and thereby keep the navigationBar.

- (void)sidebar:(RNFrostedSidebar *)sidebar didTapItemAtIndex:(NSUInteger)index {
    if (index == 0) {
        [sidebar dismissInNavigation];
        [self performSegueWithIdentifier:@"newSegue" sender:self];
    }
}

You could also just call [self removeFromParentViewController] every time in dismissAnimated:(BOOL)animated, but I think a dedicated call is more suited.

I think a lot of people is using your control with a navigationController. A test case of this scenario would be nice in your demo project, but that is up to you.

rnystrom commented 11 years ago

Why would you prefer a new method instead of calling -removeFromParentViewController?

One of the issues is removing the control before the animation completes, breaking VC containment. I'm going to have to think on this a bit. Seems there should be another solution.

mrodalgaard commented 11 years ago

Wouldn't it seem like magic having the user call [sidebar removeFromParentViewController] before the user segues? With a dedicated call, you know that the user is about to push a new viewController, and can thereby safely remove the sidebar from navigationViewController immediately. But I guess it's a matter of opinion.

You could also wait with the segue until the animation is done, though it would probably feel slow - or maybe it would work if you set sidebar's animation to false?

vinayakathawle commented 10 years ago

I have used below code but it is not working for me.

can't navigate to another view controller.

Please help me asap.