SCSlidingViewController icon indicating copy to clipboard operation
SCSlidingViewController copied to clipboard

Programmatically Open Side Menu

Open tdunham02 opened this issue 11 years ago • 13 comments

Awesome control, I'm having fun playing around with it!

Is there a way to programmatically open the side menu?

Also, the swipe to open doesn't work well when I set a large peakAmount... I have it set to 300, and I have to swipe slow, almost all the way across the screen to have it stay open. Any advice?

Thanks!

tdunham02 avatar Oct 24 '13 01:10 tdunham02

Solved the first question...

[self.slidingViewController slideRight];

tdunham02 avatar Oct 24 '13 01:10 tdunham02

Glad you're enjoying it, always good to see other people using your work :)

With regards to the speed, I think it may be due to the way I'm calculating whether or not the control should be allowed to be swiped. I'll add it to the list of things to update :) currently away for the next week and a half, but will check it out then for you!

On Wednesday, 23 October 2013 at 6:04 pm, tdunham02 wrote:

Awesome control, I'm having fun playing around with it! Is there a way to programmatically open the side menu? Also, the swipe to open doesn't work well when I set a large peakAmount... I have it set to 300, and I have to swipe slow, almost all the way across the screen to have it stay open. Any advice? Thanks!

— Reply to this email directly or view it on GitHub (https://github.com/simoncoulton/SCSlidingViewController/issues/4).

simoncoulton avatar Oct 24 '13 02:10 simoncoulton

Ok, I'm going to look into it too! Also, it seems in iOS7 when the top view is a UINavigationController, it's not possible to round the corners :/

tdunham02 avatar Oct 24 '13 16:10 tdunham02

Just posted an update which should solve the peak issue. You can set a peakThreshold, which will be a percentage of the distance between the edge of the view and the peaked amount. This way, if you set the peakAmount to 300, and the peakThreshold to 0.5, if the user drags past 140, then it will automatically continue to open. If you want to disable this, you can just set the peakThreshold to 1.

Still looking into the rounded corners...

simoncoulton avatar Nov 06 '13 03:11 simoncoulton

Awesome, I'll check that out. I'm using your control in my latest app!

tdunham02 avatar Nov 06 '13 03:11 tdunham02

Probably not the best solution, but you can always add another view controller that the navigation view controller sits in...

simoncoulton avatar Nov 07 '13 04:11 simoncoulton

Still working on a solution to rounding the corners... I'm currently trying to come up with a way to determine the topViewController class. So when a button to switch the top is touched, it checks if the top view is the one that you want to display, if it is, just call the "snapToOrigin" instead of loading the same view again.

tdunham02 avatar Nov 11 '13 20:11 tdunham02

(The difficult part of that is the fact that I have UINavigationControllers as the topViewController!)

tdunham02 avatar Nov 11 '13 21:11 tdunham02

I'm also working on that (just snapping back instead of reloading the view again)

simoncoulton avatar Nov 13 '13 00:11 simoncoulton

Awesome, I really enjoy using it, you did a great job!

tdunham02 avatar Nov 13 '13 00:11 tdunham02

Thanks dude, great to hear that you're finding it easy to work with :+1:

Check out https://github.com/simoncoulton/SCSlidingViewController/tree/1.0.4 for a working implementation of that (it's based on the restorationIdentifier). I've shuffled around the source a little too (to save duplicating the actual controls source), so it's now found in SCSlidingViewController/SCSlidingViewControllerDemo/SCSlidingViewController.

simoncoulton avatar Nov 13 '13 00:11 simoncoulton

That's great, I changed the code to this:

BOOL replaceView = YES;
    if (viewController.storyboard && [viewController.restorationIdentifier isEqualToString:self.topViewController.restorationIdentifier]) {
        replaceView = NO;
        [self snapToOrigin];
        return;
    }

So that it just snaps closed instead of animating!

tdunham02 avatar Nov 13 '13 00:11 tdunham02

Hmm yeah I actually quite like that (testing it on one of my apps at the moment). Perhaps I'll make that the default behaviour with the option of animating :+1:

simoncoulton avatar Nov 13 '13 01:11 simoncoulton