如何在ios移动应用程序中显示注销警报框
问题描述:
我正在使用phonegap运行此操作。当我在Android中运行时,注销框是正确的,它在注销框中显示“确认”作为标题。即使在ios的一切都是完美的,但注销框显示的标题为“index.html的”(这是当前页面名称)如何在ios移动应用程序中显示注销警报框
$rootScope.logout=function()
{
response=confirm(GetLocalString("HMLOGOUTMSG",_language));
if(response==true)
{
logout();
}
else
{
menuchk();
}
}
我不想标题为“index.html的”。你能否建议一种方法,不要将标题显示为“index.html”
答
在ios PhoneGap页面将显示警报中的页面名称,您需要使用插件进行通知。 要添加插件,请运行此代码。
cordova plugin add cordova-plugin-dialogs
用法
navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels])
- 消息:对话消息。 (字符串)
- confirmCallback:使用索引按钮按下(1, 2或3)或在没有按下按钮(0)的情况下解除对话框时调用的回调。 (功能)
- 标题:对话框标题。 (字符串)(可选,默认为确认)
- buttonLabels:指定按钮标签的字符串数组。 (阵列) (可选,默认为[OK,取消])
例
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(编号),这是被按下的按钮的索引。注意,索引使用一个基于索引,所以值是1,2,3,等
现在,它的做工精细,
$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']
);
}
科尔多瓦插件添加科尔多瓦 - 插件的对话框,它是开始的科尔多瓦插件或手机插件 –
@AmruthaJRaj我不明白你在评论中的意思 – byteC0de
是否像\t 科尔多瓦插件添加科尔多瓦插件对话框或phonegap插件添加科尔多瓦插件对话框 –