• ionic2/3注册安卓返回


    如果使用了

    this.app.getRootNav().push()以及this.navCtrl.push();
     
    则在注册安卓返回键的时候
      registerBackButtonAction() {
            if (!this.nativeService.isAndroid()) {
             return;
            }
            this.platform.registerBackButtonAction(() => {
             if (this.keyboard.isOpen()) {//如果键盘开启则隐藏键盘
                this.keyboard.close();
                return;
             }
             //点击返回按钮隐藏toast或loading或Overlay
             this.ionicApp._toastPortal.getActive() ||this.ionicApp._loadingPortal.getActive()|| this.ionicApp._overlayPortal.getActive();
             //隐藏modal
             let activePortal = this.ionicApp._modalPortal.getActive();
             if (activePortal) {
                activePortal.dismiss();
                return;
             }
             //页面返回
             if(this.app.getRootNav().canGoBack()){
                 //this.showExit() this.nativeService.minimize()
                    return this.app.goBack()
             }else{
                    return this.showExit();
                    
             }
            }, 10);
        }
    //双击退出提示框
        showExit() {
            if (this.backButtonPressed) { //当触发标志为true时,即2秒内双击返回按键则退出APP
                this.platform.exitApp();
            } else {
                this.nativeService.showToast('再按一次退出应用');
                this.backButtonPressed = true;
                setTimeout(() => { //2秒内没有再次点击返回则将触发标志标记为false
                    this.backButtonPressed = false;
                }, 2000)
            }
        }
  • 相关阅读:
    asp.net mvc4 之Webapi之应用客户端访问服务器端
    c#设计模式-----单例模式
    ASP.NET MVC4中ViewBag、ViewData和TempData的使用和区别
    c# winform窗体间的传值
    Extjs-树 Ext.tree.TreePanel 动态加载数据
    Entity Framework(EF)(一)之database first
    MD5加密算法
    Extjs form 表单的 submit
    XML 解析错误:找不到根元素
    C语言断言
  • 原文地址:https://www.cnblogs.com/ckAng/p/7815998.html
Copyright © 2020-2023  润新知