iOS Pan 전체 화면 슬라이딩 복귀

1601 단어

코드

- (void)viewDidLoad {
    [super viewDidLoad];

//        
    id target = self.interactivePopGestureRecognizer.delegate;

//     
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wundeclared-selector"
    UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:target action:@selector(handleNavigationTransition:)];
#pragma clang diagnostic pop
    [self.view addGestureRecognizer:pan];

//         
    self.interactivePopGestureRecognizer.enabled = NO;

    pan.delegate = self;
}

pragma mark ----

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{

    if ([[otherGestureRecognizer view] isKindOfClass:[UIScrollView class]]) {
        UIScrollView *scrollView = (UIScrollView*)[otherGestureRecognizer view];
        if (scrollView.contentOffset.x == 0) {
            return YES;
        }else{
            return NO;
        }
    }
    return YES;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
//              
    return self.childViewControllers.count > 1;
}

pragma mark ----

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
    
        viewController.hidesBottomBarWhenPushed = YES;
    }
        [super pushViewController:viewController animated:animated];
}

@end

좋은 웹페이지 즐겨찾기