1.自定义一个CustomScrollView;
- (instancetype)init
{
self = [super init];
if (self) {
_isSimultaneouslyOpen = NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openSimultaneous) name:kMessageMutiGestureOpenNoti object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(closeSimultaneous) name:kMessageMutiGestureCloseNoti object:nil];
}
return self;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return _isSimultaneouslyOpen;
}
- (void)openSimultaneous {
_isSimultaneouslyOpen = YES;
}
- (void)closeSimultaneous {
_isSimultaneouslyOpen = NO;
}
-(void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
2.在初始化JXCategoryView的VC.m中实现如下方法
- (Class)scrollViewClassInlistContainerView:(JXCategoryListContainerView *)listContainerView {
return [CustomScrollView class];
}
3.在左滑所属的VC(定义为B) .m中viewWillAppear
发出开启多手势响应通知
[[NSNotificationCenter defaultCenter] postNotificationName:kMessageMutiGestureOpenNoti object:nil];
4.在左滑所属的VC.m (定义为B)中viewDidDisappear
以及B左右两边的(或者单边)的控制器VC的viewWillAppear
中发出关闭多手势响应通知
5.以上处理后,还是会有滑动问题,需在控制器B中做以下处理,
///tableView滑动时,禁止父视图响应
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
UIScrollView *sr = (UIScrollView *) self.view.superview;
if(sr && [sr respondsToSelector:@selector(panGestureRecognizer)]){
sr.panGestureRecognizer.enabled = NO;
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
UIScrollView *sr = (UIScrollView *) self.view.superview;
if(sr && [sr respondsToSelector:@selector(panGestureRecognizer)]){
sr.panGestureRecognizer.enabled = YES;
}
}
网友评论