1. <tfoot id='oC3Vl'></tfoot>
      1. <small id='oC3Vl'></small><noframes id='oC3Vl'>

          <bdo id='oC3Vl'></bdo><ul id='oC3Vl'></ul>
        <legend id='oC3Vl'><style id='oC3Vl'><dir id='oC3Vl'><q id='oC3Vl'></q></dir></style></legend>
        <i id='oC3Vl'><tr id='oC3Vl'><dt id='oC3Vl'><q id='oC3Vl'><span id='oC3Vl'><b id='oC3Vl'><form id='oC3Vl'><ins id='oC3Vl'></ins><ul id='oC3Vl'></ul><sub id='oC3Vl'></sub></form><legend id='oC3Vl'></legend><bdo id='oC3Vl'><pre id='oC3Vl'><center id='oC3Vl'></center></pre></bdo></b><th id='oC3Vl'></th></span></q></dt></tr></i><div id='oC3Vl'><tfoot id='oC3Vl'></tfoot><dl id='oC3Vl'><fieldset id='oC3Vl'></fieldset></dl></div>

        Ionic 3:使用手机的后退按钮关闭模式

        时间:2024-04-14
            <legend id='tEIuN'><style id='tEIuN'><dir id='tEIuN'><q id='tEIuN'></q></dir></style></legend>
          • <i id='tEIuN'><tr id='tEIuN'><dt id='tEIuN'><q id='tEIuN'><span id='tEIuN'><b id='tEIuN'><form id='tEIuN'><ins id='tEIuN'></ins><ul id='tEIuN'></ul><sub id='tEIuN'></sub></form><legend id='tEIuN'></legend><bdo id='tEIuN'><pre id='tEIuN'><center id='tEIuN'></center></pre></bdo></b><th id='tEIuN'></th></span></q></dt></tr></i><div id='tEIuN'><tfoot id='tEIuN'></tfoot><dl id='tEIuN'><fieldset id='tEIuN'></fieldset></dl></div>

                  <tbody id='tEIuN'></tbody>

                <small id='tEIuN'></small><noframes id='tEIuN'>

                <tfoot id='tEIuN'></tfoot>
                  <bdo id='tEIuN'></bdo><ul id='tEIuN'></ul>
                • 本文介绍了Ionic 3:使用手机的后退按钮关闭模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我尝试在我的 Ionic 应用程序中覆盖手机的后退按钮.

                  I try to override the phone's back button in my Ionic App.

                  如果我不在页面中,此代码允许我打开一个模式来关闭应用程序,否则关闭页面.

                  This code permit me to open a modal to close the App if I'm not in a page, else close the page.

                  但这不允许我关闭打开的模式.如何检测我是否处于关闭模式?

                  But this doesn't allow me to close an opened modal. How can I detect if I'm in a modal to close it ?

                  platform.registerBackButtonAction(() => {
                  
                        let nav = app.getActiveNav();
                        let activeView: ViewController = nav.getActive();
                        console.log(activeView);
                  
                        if(activeView != null){
                          if(nav.canGoBack()) {
                            activeView.dismiss();
                          } else{
                            let alert = this.alertCtrl.create({
                              title: this.pdataManager.translate.get("close-app"),
                              message: this.pdataManager.translate.get("sure-want-leave"),
                              buttons: [
                                {
                                  text: this.pdataManager.translate.get("no"),
                                  handler: () => {
                                    this.presentedAlert = false;
                                  },
                                  role: 'cancel',
                                },
                                {
                                  text: this.pdataManager.translate.get("yes"),
                                  handler: () => {
                                    this.presentedAlert = false;
                                    this.platform.exitApp();
                                  }
                                }
                              ]
                            });
                            if(!this.presentedAlert) {
                              alert.present();
                              this.presentedAlert = true;
                            }
                          }
                        }
                      });
                    }
                  

                  推荐答案

                  您可以为您的模态框指定页面名称,您可以从应用程序的任何位置访问它.试试这个..

                  You can give page name to your modal and you can access it from anywhere in app. Try this..

                  import { App } from 'ionic-angular';
                  
                      constructor(public app: App){
                  
                      }
                  
                          platform.registerBackButtonAction(() => {
                  
                                let nav = this.app.getActiveNav();
                                let view = nav.getActive().instance.pageName;
                  
                  
                                if (view == YOU_PAGE_NAME) {
                                  //You are in modal
                                } else {
                                  //You are not in modal
                                }
                          });
                  

                  在你的模式中

                  pageName = 'YOU_PAGE_NAME';
                  

                  这篇关于Ionic 3:使用手机的后退按钮关闭模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:由于“_alwaysRunsAtForegroundPriority",Ionic 应用程序在 iOS 12. 下一篇:IONIC 3 IOS 无法从文件中读取数据

                  相关文章

                  <legend id='t0aT1'><style id='t0aT1'><dir id='t0aT1'><q id='t0aT1'></q></dir></style></legend>
                • <tfoot id='t0aT1'></tfoot>

                      <small id='t0aT1'></small><noframes id='t0aT1'>

                    1. <i id='t0aT1'><tr id='t0aT1'><dt id='t0aT1'><q id='t0aT1'><span id='t0aT1'><b id='t0aT1'><form id='t0aT1'><ins id='t0aT1'></ins><ul id='t0aT1'></ul><sub id='t0aT1'></sub></form><legend id='t0aT1'></legend><bdo id='t0aT1'><pre id='t0aT1'><center id='t0aT1'></center></pre></bdo></b><th id='t0aT1'></th></span></q></dt></tr></i><div id='t0aT1'><tfoot id='t0aT1'></tfoot><dl id='t0aT1'><fieldset id='t0aT1'></fieldset></dl></div>

                        <bdo id='t0aT1'></bdo><ul id='t0aT1'></ul>