公司APP类似Uber,从最左侧滑动会出现菜单,但需要用到地图,添加全屏的tap手势会产生冲突,求大神支招,如何结局啊?急急急
大家讲道理2017-04-17 17:39:41
Do you want it to only work if you swipe right from the left edge of the screen? If so, adding an edge gesture will do the trick! As follows:
- (void)viewDidLoad {
[super viewDidLoad];
UIScreenEdgePanGestureRecognizer* screenEdgePan = [[UIScreenEdgePanGestureRecognizer alloc]initWithTarget:self action:@selector(action:)];
screenEdgePan.edges = UIRectEdgeLeft;
[self.view addGestureRecognizer:screenEdgePan];
}
-(void)action:(UIScreenEdgePanGestureRecognizer*)sender{
if (sender.edges == UIRectEdgeLeft) {
NSLog(@"正在从左边滑动");
switch (sender.state) {
case UIGestureRecognizerStateBegan:
NSLog(@"手势开始");
break;
case UIGestureRecognizerStateChanged:
NSLog(@"手势进行中");
break;
case UIGestureRecognizerStateEnded:
NSLog(@"手势结束");
break;
default:
break;
}
}
}
天蓬老师2017-04-17 17:39:41
I don’t know ios, but in Android it can be limited by judging the x coordinate position of the first point. This is just an idea, I haven’t tried it. I wonder if there is a similar idea for ios