Question

I'm currently using ECSlidingViewController 2 in my iOS 7 app. I've successfully implemented the ECSlidingViewController 2, however i'm having a minor issue when I am sliding the topViewController. When I am run the project for the first time , sliding the topViewController from left to right to reveal menu controller works fine. But the strange thing is that when I click on any of the menu items like 'First Screen', 'Second Screen' or 'Home screen' it stops this sliding behavior permanently.

I have uploaded my work on github. https://github.com/rajuptb/ECSlidingViewControllerTest

I have included the following in app delegate. [navigationController.view addGestureRecognizer:self.slidingViewController.panGesture];

I followed the LayoutDemo in examples of ECSlidingViewController for doing this. Because of some specific projet requirements I want to initiate the topViewController & underLeftViewController from the app delegate.

Any help, suggestions, or even guesses as to what might be the problem is much appreciated.

Was it helpful?

Solution

The panGesture you add to the navigation controller in the app delegate stays with that navigation controller's view. You initialize sliding view controller with that navigation controller, so the panning gesture works while that navigation controller is the top view controller. Once you change the top view controller, the panning gesture is gone (since it was attached to that navigation controller's view).

You need to add the panGesture back to another view (most likely on the new top view controller's view or one of its subviews). One way to do this is in viewDidLoad for each of your view controllers that will become sliding view controller's top view controller.

In your First, Second, and Home view controllers:

#import "UIViewController+ECSlidingViewController.h"

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view addGestureRecognizer:self.slidingViewController.panGesture];
}

This enables panning on the view. If you wanted to enable panning on the entire navigation controller view, then you would add it there: [self.navigationController.view addGestureRecognizer:self.slidingViewController.panGesture].

ECSlidingViewController makes no assumption about how you want your users to interact with it. It's up to you to decide on how it works within the context of your app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top