公司APP类似Uber,从最左侧滑动会出现菜单,但需要用到地图,添加全屏的tap手势会产生冲突,求大神支招,如何结局啊?急急急
大家讲道理2017-04-17 17:39:41
你是想要只能從螢幕的左邊邊緣向右滑動才有效麼?如果是的話,加上一個邊緣手勢就可以解決!如下:
- (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;
}
}
}