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 disable swipe from anywhere in screen? #9

Open
anhhtbk opened this issue Sep 14, 2016 · 3 comments
Open

How to disable swipe from anywhere in screen? #9

anhhtbk opened this issue Sep 14, 2016 · 3 comments

Comments

@anhhtbk
Copy link

anhhtbk commented Sep 14, 2016

I want to disable swipe from anywhere in screen to open menu, only swipe from edge of screen.

@anhhtbk
Copy link
Author

anhhtbk commented Sep 14, 2016

In file SlideMenuController.m
I edit:

-(BOOL)isLeftPointContainedWithinBezelRect:(CGPoint)point {
    CGRect leftBezelRect = CGRectZero;
    CGRect tempRect = CGRectZero;
//    CGFloat bezelWidth = CGRectGetWidth(self.view.bounds) - options.leftBezelWidth;
    CGRectDivide(self.view.bounds, &leftBezelRect, &tempRect, options.leftBezelWidth/*bezelWidth*/, CGRectMinXEdge);
    return CGRectContainsPoint(leftBezelRect, point);
}

And it work!

@MeGaPk
Copy link

MeGaPk commented Nov 22, 2016

+1, it is work good.
Very bad idea, work swipe anywhere in screen... Good luck use google maps :D

@accidbright
Copy link

accidbright commented Nov 1, 2017

I faced the same issue.
@anhhtbk found correct solution. It looks like the bug in this method. Found 2 ways to solve:

  1. Use fix by @anhhtbk instead.
-(BOOL)isLeftPointContainedWithinBezelRect:(CGPoint)point {
    CGRect leftBezelRect = CGRectZero;
    CGRect tempRect = CGRectZero;
    CGRectDivide(self.view.bounds, &leftBezelRect, &tempRect, options.leftBezelWidth, CGRectMinXEdge);
    return CGRectContainsPoint(leftBezelRect, point);
}
  1. I used this controller from cocoapods, so code edition is not very good idea for me. The workaround is in reverse idea. In the original (buggy) method implementation options.leftBezelWidth means the part of screen, that should not recognize swipe. But you expect, that this is a part of screen, that should recognize swipe. You can set this value as difference between whole screen width and expected bezel width. So you can temporary fix (until this issue won't be fixed) by setting somewhere in code anything like this:
CGFloat yourExpectedBezelWidth = 16.0f;
slideViewController.option.leftBezelWidth = slideViewController.view.frame.width - yourExpectedBezelWidth;

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

3 participants