Search code examples
iosobjective-cecslidingviewcontroller

How to know when menu is "open" using ECSlidingViewController


I am using the ecsliding for a menu in my app. I was wondering how to know when the menu is open and when it has control. I am trying to do themes in the menu and am having issues because I "reset" the colours on viewdidload and viewdidappear (for the main "top" view controller").

Essentially :

User opens menu, selects colour, closes menu and colours should change... but since the rightviewcontroller is not actually being fully "added" I don't think the viewdidload and viewdidappear methods get called when I close the menu...

Sorry for the rambling...

Any help?

Thanks

Andy


Solution

  • According to the docs you should be able to interrogate the currentTopViewPosition property.

    This is defined as

    typedef NS_ENUM(NSInteger, ECSlidingViewControllerTopViewPosition) {
        /** The top view is on anchored to the left */
        ECSlidingViewControllerTopViewPositionAnchoredLeft,
        /** The top view is on anchored to the right */
        ECSlidingViewControllerTopViewPositionAnchoredRight,
        /** The top view is centered */
        ECSlidingViewControllerTopViewPositionCentered
    };
    

    It looks like you can access the instance of ECSlidingViewController that contains your view controller using the UIViewController(ECSlidingViewController)category methodslidingViewController`