在網(wǎng)上搜羅了一些方法闷畸,因?yàn)槲夷壳绊?xiàng)目中的界面比較復(fù)雜,所以一些方法已被pass掉模蜡,目前還有以下方法可用漠趁。
方案一:
//當(dāng)前為側(cè)滑手勢(shì)的時(shí)候設(shè)置scrollview手勢(shì)失效才即可
NSArray *gestureArray = self.navigationController.view.gestureRecognizers;
for (UIGestureRecognizer *gesture in gestureArray) {
if ([gesture isKindOfClass:[UIScreenEdgePanGestureRecognizer class]]) {
[self.bottomView.panGestureRecognizer requireGestureRecognizerToFail:gesture];
}
}
+1s
[_smallScrollView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
[_bigScrollView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
方案二:新建繼承自UIScrollView的類,然后將當(dāng)前控制器中的ScrollView替換忍疾,在.m中重寫一下方法
#import <UIKit/UIKit.h>
@interface BottomScrollView : UIScrollView
{
BOOL isBack;
}
@end
#import "BottomScrollView.h"
@implementation BottomScrollView
-(BOOL) gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
if([self panBack:gestureRecognizer]) {
return NO;
}
return YES;
}
- (BOOL)panBack:(UIGestureRecognizer*)gestureRecognizer{
if(gestureRecognizer == self.panGestureRecognizer) {
UIPanGestureRecognizer *pan = (UIPanGestureRecognizer*)gestureRecognizer;
CGPoint point = [pan translationInView:self];
UIGestureRecognizerState state = gestureRecognizer.state;
if(UIGestureRecognizerStateBegan== state ||UIGestureRecognizerStatePossible== state) {
CGPoint location = [gestureRecognizer locationInView:self];
if(point.x>0&& location.x<150&&self.contentOffset.x<=0) {
isBack=YES;
return YES;
}
}
}
return NO;
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(nonnull UIGestureRecognizer*)otherGestureRecognizer{
if(isBack) {
isBack=NO;
return YES;
}else{
return NO;
}
}
@end
非常感謝各位大佬的分享與交流闯传,也希望我的發(fā)布能夠幫助到跟多的人。