1

is there any way to use the ECSlidingViewController to slide the menu from right to left ? the default is left to right

this code is working, the menu slide from left to right:

- (IBAction)menuButtonTapped:(id)sender {
        [self.slidingViewController anchorTopViewToRightAnimated:YES];
}

this code is not working, i want the menu slide from right to left:

- (IBAction)menuButtonTapped:(id)sender {
        [self.slidingViewController anchorTopViewToLeftAnimated:YES];
}
user1172579
  • 575
  • 1
  • 7
  • 22
  • It can slide both ways, what do you mean? – Wain Mar 11 '14 at 18:04
  • The default is [self.slidingViewController anchorTopViewToRightAnimated:YES]; when the menu button is tapped. the menu slide from right to left, but if i change the code to [self.slidingViewController anchorTopViewToLeftAnimated:YES]; nothing happen. – user1172579 Mar 13 '14 at 03:05
  • Show code for how you have configured the sliding controller. – Wain Mar 13 '14 at 08:21
  • Hi Wain, pls find the updated code above – user1172579 Mar 13 '14 at 10:03
  • Configuration - how you setup the sliding controller with the top, left and right controllers. What peek amounts? What version of sliding controller (1 or 2)? – Wain Mar 13 '14 at 10:15
  • Thanks Wain, i found that i didn't declare the key path: underRightViewControllerStoryboardId of the ESSlidingViewController. After add it back. the menu can slide from right to left ! thx ! – user1172579 Mar 13 '14 at 17:40

1 Answers1

3

This will do the trick.

  [self.slidingViewController resetTopViewAnimated:YES onComplete:^(){
    [self.slidingViewController performSelectorOnMainThread:@selector(anchorTopViewToLeftAnimated:) withObject:nil waitUntilDone:NO];
  }];

Here's whats happening: ECSlidingViewContorller has an enum struct of different transitions it supports, and it does not support sliding from anchor right, to anchor left. This, should likely be added as a feature, and an issue should be created.

So instead, you have to stack the two actions in sequence.... BUT, if you look at the code, it will run your oncomplete, before it has update its state.

Since this should be happening in the main thread (since its a UI event), you can add the next action to that thread and it will actually happen afterwards.

This will not work if you want to disable animation.

jkatzer
  • 724
  • 7
  • 12