Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to open, close left and right menues? #90

Closed
ancienttottenham opened this issue Aug 23, 2013 · 7 comments
Closed

How to open, close left and right menues? #90

ancienttottenham opened this issue Aug 23, 2013 · 7 comments

Comments

@ancienttottenham
Copy link

Hi.
At first, thank you for great job.

My Question.
I have a left and right menues.
There is a button in left menu, which pushing content segue to nav controller, which has 2 view controllers ( root View controller and connected to him view controller with push segue).
In rootVC both menues (left & right) works as needed, but when i tap on some button and pushing to 2nd VC, then the right button is disappearing in nav bar , and i lost right menu there ( I can open it ONLY when i swiping to left , but in my case I disablePanGesture in this indexPath).

How can i set back right button, and open right menu by tapping on it ?

Also ,please tell me how to open, close, enable or disable left and right menues programmatically, without changing Your code .
Because there is

  • doSlideToSide
  • doSlideToLeftSide
  • doSlideOut:complete
  • doSlideIn:complete

methods in your code (in SASlideMenuRootViewController.m), but these methods are private , and we can't use them without make them public ourself :)

Thank You.

@stefanoa
Copy link
Owner

What you are asking is not currently supported, I am not sure it is easy to do but I will check it.
About your second question, to intercept the sliding events and apply some logic there is the SASlideMenuDelegate protocol. There are methods to override for each of the sliding events:

@protocol SASlideMenuDelegate <NSObject>

@optional

-(void)slideMenuWillSlideToSide:(UINavigationController*) selectedContent;
-(void)slideMenuDidSlideToSide:(UINavigationController*) selectedContent;

-(void)slideMenuWillSlideIn:(UINavigationController*) selectedContent;
-(void)slideMenuDidSlideIn:(UINavigationController*) selectedContent;

-(void)slideMenuWillSlideOut:(UINavigationController*) selectedContent;
-(void)slideMenuDidSlideOut:(UINavigationController*) selectedContent;

-(void) slideMenuWillSlideToLeft:(UINavigationController*) selectedContent;
-(void) slideMenuDidSlideToLeft:(UINavigationController*) selectedContent;

@end

I hope this helps

@ancienttottenham
Copy link
Author

Yes, this delegate methods are helpful sometimes in some cases,
but there is a many times, when we need to open right (or left) menu programmatically.
E.g. when there is no navigation bar , accordingly there is no menu button.There is only map view , so pan gesture will not work to open menu. On the map view placed a button, and when user press on it, menu must be open.
So how to realize this ?

@stefanoa
Copy link
Owner

Ok, now I understand.
The only available option is to use the SASlideViewController method:

-(void)selectContentAtIndexPath:(NSIndexPath *)indexPath scrollPosition:(UITableViewScrollPosition)scrollPosition;

The problem is that it is useful if you need to switch to a different content viewcontroller but if you only need to show the menu, currently there is no support for that.
I will have a look at it it should not be very difficult.

stefanoa added a commit that referenced this issue Aug 23, 2013
@stefanoa
Copy link
Owner

I have added two methods to the SASlideMenuViewController:

-(void) revealLeftMenu;
-(void) revealRightMenu;

The Static test uses revealLeftMenu, in the LightViewController I added a button to test it.
The Dynamic test uses revealRightMenu, in the GreenViewController if you tap the controller the right menu is revealed.

@ancienttottenham
Copy link
Author

Yes, now it works. But only for left menu.
You have an issue with opening right menu by -(void) revealRightMenu;

In that function, you call
[self.slideMenuDataSource hasRightMenuForIndexPath:self.selectedIndexPath];

wich always return indexPath at (0,0), because in ExampleStatic VC you have
-(NSIndexPath*) selectedIndexPath
{
return [NSIndexPath indexPathForRow:0 inSection:0];
}

Furthermore , calling only [self.rootController doSlideToLeftSide] method not enough, because the rightMenu will not added while pan gesture state is not began and direction is not "to left" (or rightMenuButton is not tapped).
Accordingly , first you mast do this:
if (self.rootController.isRightMenuEnabled && self.rootController.rightMenu != nil)
{
[self.rootController addRightMenu];
}

before [self.rootController doSlideToLeftSide] ,
if I understand your code correctly :)

Here is an updated project.

http://www.mediafire.com/download/slhuy7xmt99rmea/SASlideMenu-master.zip

stefanoa added a commit that referenced this issue Aug 24, 2013
…ddRightMenu call and changed the check for the menu existence.

#90
@stefanoa
Copy link
Owner

Good catch!!
The new version uses the addRightMenu method and I also changed the check for the existence of the rightMenu. I removed the call to hasRightMenuForIndexPath: because it is redundant, if the rightMenu is there and is enabled I will reveal it.

Thank You for the precise feedback.

@ancienttottenham
Copy link
Author

Glad to help you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants