SlideMenuControllerOC icon indicating copy to clipboard operation
SlideMenuControllerOC copied to clipboard

How to disable swipe from anywhere in screen?

Open anhhtbk opened this issue 8 years ago • 3 comments

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

anhhtbk avatar Sep 14 '16 07:09 anhhtbk

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!

anhhtbk avatar Sep 14 '16 07:09 anhhtbk

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

MeGaPk avatar Nov 22 '16 12:11 MeGaPk

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;

accidbright avatar Nov 01 '17 13:11 accidbright