我正在尝试创建一个WinJS.UI.Flyout,其中包含一个单独的输入字段和一个单独的按钮,以允许用户在输入字段中输入新值,并单击按钮保存它。然而,在Windows Phone 8.1上,不支持Flyouts。
有什么方法可以解决这个问题吗?是否有一种方法可以在手机8.1上模仿WinJS.UI.Flyout组件的行为?
提前致谢。
有什么方法可以解决这个问题吗?是否有一种方法可以在手机8.1上模仿WinJS.UI.Flyout组件的行为?
提前致谢。
我认为没有相关的控件......而且我不认为我会希望在手机上使用它。您可以查看日历应用程序中的日期和时间选择器,它们将带您进入新的“页面”以输入数据。
您想要做的事情可以通过标准HTML实现,但我只是不确定是否需要它。
在这些情况下,我会带我的用户去一个新页面,让他们输入所需的数据。
/* Used to help emulate the Flyout when on a Windows Phone device. */
.matting {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
z-index: 999;
background-color: black;
opacity: 0.6;
display: none;
}
/* Applied when forcing a Flyout on a Windows Phone device. */
/* Removed when hiding it. */
/* Creates it like a WP dialog. */
.wp-flyout {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
/* The height should be left alone. */
z-index: 1000;
display: block;
opacity: 1.0;
background-color: dimgray;
}
<div id="matting" class="matting"></div>
ready
和unload
函数之外,我还有以下两个额外的函数: // Shows a flyout, even on Windows Phone.
// flyoutId is the WinJS.UI.Flyout structure.
// launchButtonId is the button that is launching this flyout.
Flyout: function (flyoutId, launchButtonId) {
var flyoutElement = document.getElementById(flyoutId);
if (flyoutElement.winControl) {
// Windows.
var launchButton = document.getElementById(launchButtonId);
flyoutElement.winControl.show(launchButton);
} else {
// Windows Phone.
// Fake it with a dialog.
var flyout = WinJS.Utilities.query("#" + flyoutId);
// Show the matting.
var matting = WinJS.Utilities.query("#matting");
matting.setStyle("display", "block");
// Apply click-cancel to the matting.
matting[0].cancel = function () { that.UnFlyout(flyoutId); return true; };
matting.listen("click", matting[0].cancel, false);
// Apply the wp-flyout class.
flyout.addClass("wp-flyout");
// Add back-button-cancel event.
WinJS.Application.addEventListener("backclick",
matting[0].cancel);
// Show the flyout.
flyout.setStyle("display", "block");
}
},
// Hides a flyout, even on Windows Phone.
UnFlyout: function (flyoutId) {
var flyoutElement = document.getElementById(flyoutId);
if (flyoutElement.winControl) {
// Windows.
flyoutElement.winControl.hide();
} else {
// Windows Phone.
// We're faking it with a dialog.
var flyout = WinJS.Utilities.query("#" + flyoutId);
// Hide the flyout.
flyout.setStyle("display", "none");
// Remove the wp-flyout class.
flyout.removeClass("wp-flyout");
// Remove the click-cancel from the matting.
var matting = WinJS.Utilities.query("#matting");
matting.removeEventListener("click", matting[0].cancel, false);
// Remove back-button-cancel event.
WinJS.Application.removeEventListener("backclick",
matting[0].cancel);
// Hide the matting.
matting.setStyle("display", "none");
}
}
that.Flyout("flyoutId", "launchButtonId");
that.UnFlyout("flyoutId");
在正常的“.hide()”之外,可以使用它。
随意尝试,并让我知道您是否有任何改进。