2

how can I handled event when Left menu hided. For example: On home screen I have a table with items On left side Menu I have a category list, when I selected the item on the left menu I assign value of a global variable and go to back to main top View where I want run new query and update tableView items.

Thanks!

2 Answers2

0

You should implement the following method in your category list controller

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

For instance, my LeftMenu was basically a UITableviewController (Same as in the ECSlidingViewController basic demo), I needed to filter the items shown in TopViewController based on what row was tapped in the LeftMenu, here is how I did it:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
//To stop TopViewController from being reset each time.
ECSlidingSegue *slidingSegue = (ECSlidingSegue *)segue;
slidingSegue.skipSettingTopViewController = YES;

//getting the dataobject associated with the selected table row
NSIndexPath *selectedIndexPath = [_tableView indexPathForSelectedRow];
MyDataObject *dataObject = [_dataArray objectAtIndex:selectedIndexPath.row];

//Digging down into the hiearchy to get to my required view
UITabBarController *tabBarController = (UITabBarController *)[[segue destinationViewController] topViewController];

UINavigationController *navigationController = [[tabBarController viewControllers] objectAtIndex:0];

MyFilteredListViewController *filteredListViewController = (MyFilteredListViewController *)[navigationController topViewController];

//Calling a method on the viewcontroller
[filteredListViewController filterForDataObject:dataObject];

}

So I had to dig down a little to find the viewcontroller that I specifically needed because MyFilteredListViewController was inside a Navigation Controller which was in turn a child of TabBarController which was then set as the TopViewController of the ECSlidingViewController.

It should be more straight forward to access viewcontrollers if they are not nested in a complex manner :)

Once you have the view controller that you require then you can call a method on it (as I did) or you could access a variable property and set its value.

You will have to import "ECSlidingSegue.h" into your category list controller.

Hope this helps!

Shumais Ul Haq
  • 1,427
  • 1
  • 15
  • 26
0

If I understood correctly what you want to do, you can set your topviewcontroller as delegate of the sliding ECSlidingViewController

Then on your topviewcontroller you can implement the optional

- (id<UIViewControllerAnimatedTransitioning>)slidingViewController:(ECSlidingViewController *)slidingViewController
                               animationControllerForOperation:(ECSlidingViewControllerOperation)operation
                                             topViewController:(UIViewController *)topViewController;

That's a good point to perform any custom action you want before the animation of the topviewcontroller occurs.. if you don't want custom animations/transitions to happen, remember to return nil after your custom code.

alasker
  • 309
  • 5
  • 18