zoukankan      html  css  js  c++  java
  • 全屏滑动返回

    #import "XMGNavigationViewController.h"
    
    @interface XMGNavigationViewController ()<UIGestureRecognizerDelegate>
    
    @end
    
    @implementation XMGNavigationViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
    
        UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self.interactivePopGestureRecognizer.delegate action:@selector(handleNavigationTransition:)];
        
        [self.view addGestureRecognizer:pan];
        
        // 控制手势什么时候触发,只有非根控制器才需要触发手势
        pan.delegate = self;
        
        // 禁止之前手势
        self.interactivePopGestureRecognizer.enabled = NO;
        
        // 假死状态:程序还在运行,但是界面死了.
        
        /*
            为什么导航控制器的手势不是全屏滑动 =>
         */
        
    }
    
    #pragma mark - UIGestureRecognizerDelegate
    // 决定是否触发手势
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
    {
        return self.childViewControllers.count > 1;
    }
    
    // <_UINavigationInteractiveTransition: 0x7f9c948302a0>:手势代理
    
    /*
     UIPanGestureRecognizer
     
     UIScreenEdgePanGestureRecognizer:导航滑动手势
     target=<_UINavigationInteractiveTransition 0x7fdc4a740440>)
     action=handleNavigationTransition:
     
     
     <UIScreenEdgePanGestureRecognizer: 0x7fdc4a740120; state = Possible; delaysTouchesBegan = YES; view = <UILayoutContainerView 0x7fdc4a73e690>; target= <(action=handleNavigationTransition:, >>
    
     */
    
    - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
    {
        if (self.childViewControllers.count > 0) { // 非根控制器
            
            // 恢复滑动返回功能 -> 分析:把系统的返回按钮覆盖 -> 1.手势失效(1.手势被清空 2.可能手势代理做了一些事情,导致手势失效)
            
            // 设置返回按钮,只有非根控制器
            viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem backItemWithimage:[UIImage imageNamed:@"navigationButtonReturn"] highImage:[UIImage imageNamed:@"navigationButtonReturnClick"]  target:self action:@selector(back) title:@"返回"];
        }
        
        // 真正在跳转
        [super pushViewController:viewController animated:animated];
        
    }
    
    
    
    @end
  • 相关阅读:
    【2019】微软Power BI 每月功能更新系列——Power BI 10月版本功能完整解读
    教你写一个含信息的汇编程序
    为安卓手机刷上手机kali系统Nethunter
    多年珍藏的55w御剑字典
    netsh命令获取wifi历史连接密码
    win7/10获取本地wifi密码明文
    Wordpress综合检测和爆破工具
    那些年我们一起追逐过的安全工具
    大部分政府网站U-mail存在直接拿shell漏洞
    无需密码攻击 Microsoft SQL Server
  • 原文地址:https://www.cnblogs.com/xufengyuan/p/6503140.html
Copyright © 2011-2022 走看看