Closed HatsuneMikuV closed 7 years ago
我重写了代理的方法
如下 是不是有问题?
(BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer {
// Ignore when no view controller is pushed into the navigation stack. if (self.navigationController.viewControllers.count <= 1) { return NO; }
// Disable when the active view controller doesn't allow interactive pop. UIViewController *topViewController = self.navigationController.viewControllers.lastObject; if (topViewController.fd_interactivePopDisabled) { return NO; }
// Ignore pan gesture when the navigation controller is currently in transition. if ([[self.navigationController valueForKey:@"_isTransitioning"] boolValue]) { return NO; } // Prevent calling the handler when the gesture begins in an opposite direction. CGPoint translation = [gestureRecognizer translationInView:gestureRecognizer.view]; if (translation.x <= 0) { return NO; }
CGPoint touchPoint = [gestureRecognizer locationInView:gestureRecognizer.view];
NSString videoId = self.contentModel.video.videoId; if (videoId == nil || [videoId isEqualToString:@""]) { return YES; }else { if (touchPoint.y <= SCREEN_WIDTH 9 / 16.0 + 64) { return NO; } return YES; } return YES; }
找到方法了 不需要重写
修改了你们的库
添加属性 /// Max not allowed initial distance to top edge when you begin the interactive pop /// gesture. 0 by default, which means it will ignore this limit. @property (nonatomic, assign) CGFloat fd_interactivePopMaxAllowedInitialDistanceToHeightEdge;
return [objc_getAssociatedObject(self, _cmd) doubleValue];
return [objc_getAssociatedObject(self, _cmd) floatValue];
}
(void)setFd_interactivePopMaxAllowedInitialDistanceToHeightEdge:(CGFloat)distance {
SEL key = @selector(fd_interactivePopMaxAllowedInitialDistanceToHeightEdge); objc_setAssociatedObject(self, key, @(MAX(0, distance)), OBJC_ASSOCIATION_RETAIN_NONATOMIC); }
在使用的时候 添加判断
CGPoint beginningLocation = [gestureRecognizer locationInView:gestureRecognizer.view];
// Ignore when the beginning location is beyond max allowed initial distance to left edge. CGFloat maxAllowedInitialDistance = topViewController.fd_interactivePopMaxAllowedInitialDistanceToLeftEdge; if (maxAllowedInitialDistance > 0 && beginningLocation.x > maxAllowedInitialDistance) { return NO; } // Ignore when the beginning location is beyond max not allowed initial distance to top edge. CGFloat maxAllowedInitialHeightDistance = topViewController.fd_interactivePopMaxAllowedInitialDistanceToHeightEdge; if (maxAllowedInitialHeightDistance > 0 && beginningLocation.y < maxAllowedInitialHeightDistance) { return NO; }
希望大佬们有空能完善一下,丰富用法
@sunnyxx 希望能丰富一下,增加高度判断滑动区域,因为跟视频相关的界面,视频是不能被侧滑的
@HatsuneMikuV 这个是禁止侧滑的,在跟视频相关的界面这么操作是不是可以?
To disable this pop gesture of a view controller:
viewController.fd_interactivePopDisabled = YES;
@afantree viewController.fd_interactivePopDisabled = YES; 这样禁止了全部不能侧滑 而现在好多视频APP基本是视频部分不能侧滑,而视频下面的内容部分是可以侧滑的 例如acfun
手机系统是8.4 使用了FDFullscreenPopGesture 然后从A push到B 使用手势滑动返回,出现了崩溃的BUG 提示 跟
@property(nonatomic, copy) NSArray<NSNumber > allowedTouchTypes NS_AVAILABLE_IOS(9_0); // Array of UITouchTypes as NSNumbers. @property(nonatomic, copy) NSArray<NSNumber > allowedPressTypes NS_AVAILABLE_IOS(9_0); // Array of UIPressTypes as NSNumbers.
这个两个属性有关