【问题标题】:How to display logout alert box in ios mobile application如何在 ios 移动应用程序中显示注销警报框
【发布时间】:2017-08-01 09:15:17
【问题描述】:

我正在使用 phonegap 运行它。当我在 Android 中运行时,注销框是正确的,并且它在注销框中显示“确认”作为标题。即使在 ios 中一切都很完美,但注销框显示标题为“index.html”(这是当前页面名称)

                         $rootScope.logout=function()
                        {

                  response=confirm(GetLocalString("HMLOGOUTMSG",_language));
                            if(response==true)
                            {
                                logout();
                            }
                            else
                            {
                                menuchk();
                            }
                        }

我不希望标题为“index.html”。你能建议一种不将标题显示为“index.html”的方法

【问题讨论】:

    标签: android angularjs mobile-application phonegap


    【解决方案1】:

    在ios PhoneGap 页面会在alert 中显示页面名称,您需要使用插件进行通知。 要添加插件,请运行此代码。

    cordova plugin add cordova-plugin-dialogs
    

    用法

    navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels])
    
    • message:对话框消息。 (字符串)
    • confirmCallback:按下按钮索引调用的回调(1, 2 或 3) 或在没有按下按钮的情况下关闭对话框 (0)。 (函数)
    • title:对话框标题。 (字符串)(可选,默认为确认)
    • buttonLabels:指定按钮标签的字符串数组。 (大批) (可选,默认为 [OK,Cancel])

    例子

    function onConfirm(buttonIndex) {
        alert('You selected button ' + buttonIndex);
    }
    
    navigator.notification.confirm(
        'You are the winner!', // message
         onConfirm,            // callback to invoke with index of button pressed
        'Game Over',           // title
        ['Restart','Exit']     // buttonLabels
    );
    

    回调接受参数 buttonIndex (Number),它是按下按钮的索引。注意索引使用从一开始的索引,所以取值为1、2、3等。

    Documentation

    现在它工作正常,

    $rootScope.logout = function () {
        function onConfirm(buttonIndex) {
            if (buttonIndex == 1) {
                logoutfunc();
            }
            else {
                menuopenchk();
            }
        }
    
        navigator.notification.confirm(
            'Are you sure to logout?',
            onConfirm,
            'Logout',
            ['Yes', 'Not Now']
        );
    }
    

    【讨论】:

    • cordova plugin add cordova-plugin-dialogs , 是cordova plugin 还是phonegap plugin in start
    • @AmruthaJRaj 我不明白你在评论中的意思
    • 是像cordova插件添加cordova-plugin-dialogs还是phonegap插件添加cordova-plugin-dialogs
    • navigator.notification.confirm('确定要注销吗?', onConfirm(buttonIndex), '注销', ['Yes','Not Now'] );是这样的吗??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多