关于PPRevealSideViewController第三方抽屉的改善

陈刚洁
2023-12-01
因为项目中用到了抽屉视图,所以引用了PPRevealSideViewController这个第三方库,用过的人想必都知道这个第三方抽屉虽然好用,但是太容易滑动了,如果放一个tableview在上面很容易误滑就滑到了别的界面,所以在PPRevealSideViewController.m中加上这个方法

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

    AppDelegate * app = (AppDelegate *)[UIApplication sharedApplication].delegate;
    UIWindow * window2 = app.window;
    
    UITouch * touch = touches.anyObject;
    CGPoint location2 = [touch locationInView:window2];
    NSLog(@"%@",NSStringFromCGPoint(location2));
    if (location2.x > 40 && location2.x < APP_WIDTH-40) {
        self.isPanGestureDidPan = NO;
    } else {
        self.isPanGestureDidPan = YES;
    }
}

同时加一个属性,定义为BOOL即可,通过这个BOOL值在下面的方法中判断,如果是NO直接return即可。

- (void)gestureRecognizerDidPan:(UIPanGestureRecognizer *)panGesture 




/********************************************************************************************************************************************************************************************************/
上述错误,按上述修改存在bug

所以重新想了一下,还是将touchBegan:(NSSet *)touches withEvent:(UIEvent *)event在拖拽手势中重写。
重写一个手势即可
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    AppDelegate * app = (AppDelegate *)[UIApplication sharedApplication].delegate;
    UIWindow * window2 = app.window;
    
    UITouch * touch = touches.anyObject;
    CGPoint location2 = [touch locationInView:window2];
    NSLog(@"%@",NSStringFromCGPoint(location2));
    if (location2.x > 40 && location2.x < APP_WIDTH-40) {
    } else {
        [super touchesBegan:touches withEvent:event];

    }
}



 类似资料: