SlideMenuControllerOC
SlideMenuControllerOC copied to clipboard
How to disable swipe from anywhere in screen?
I want to disable swipe from anywhere in screen to open menu, only swipe from edge of screen.
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!
+1, it is work good. Very bad idea, work swipe anywhere in screen... Good luck use google maps :D
I faced the same issue. @anhhtbk found correct solution. It looks like the bug in this method. Found 2 ways to solve:
- 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);
}
- 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;