【问题标题】:Windows phone 8 and phonegap 2.7.0, Navigation between HTML pages and Xaml and backWindows phone 8 和 phonegap 2.7.0,在 HTML 页面和 Xaml 之间导航并返回
【发布时间】:2013-12-03 14:54:44
【问题描述】:

我正在开发一个应用程序,它将具有单独的相机功能。原因是我不喜欢 phonegap 在 getPicture for windows phone 中的内置功能,因为它会自动将图像保存在用户设备上,这会占用大量内存。

我的应用目前是如何工作的,

用户打开应用程序,应用程序将他们引导到 login.html 页面(他们在其中输入用户名/密码)然后到 menu.html,在那里他们有许多不同的选项/功能,其中一个是拍照按钮,它可以打开相机camera.html 页面中的 .html 我有这个,代码调用我的单独 Echo.cs 类/插件工具

        cordova.exec(function (imageData) { onPhotoDataSuccess(imageData); }, function (err) {
            alert("Intent Error. Unable to call update routines");
        }, "Echo", "takePicture", ["takepicture"]);

我的 takePicture 方法如下所示:

    public void takePicture(string options)
    {
        string takePic = null;
        Debug.WriteLine("Reached imageconvert method");
        try
        {
            string[] data = JsonHelper.Deserialize<string[]>(options);
            takePic = data[0];


        }
        catch (Exception)
        {
            Debug.WriteLine("ERROR OCCURED!");
            DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
            return;
        }


        if ((takePic != null) && (takePic.Length > 0))
        {
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/Camera.xaml", UriKind.Relative));

                //logic here some way to get the image back from camera.xaml and resume my currant page.
            });


            //DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "imaged passed back from camera.xaml should go here"));
        }
        else
        {
            DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Expected one non-empty string argument."));
            return;
        }
    }

上面的这段代码将用户重定向到我构建的单独的 camera.xaml 页面,我的自定义相机在该页面处理图像而不将其保存到用户库并将其转换为编码的 64basestring 以作为 ImageData 发送回,我现在的问题是,有没有办法以某种方式将 ImageData 信息发回并从 Camera.html 页面恢复我的应用程序? phonegap 也能做到这一点吗?

【问题讨论】:

  • 你能解决上述问题吗?

标签: c# javascript cordova windows-phone-8


【解决方案1】:

我曾经背过:

DispatchCommandResult(new PluginResult(PluginResult.Status.OK, "imaged passed back from   camera.xaml should go here"));
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
    root = Application.Current.RootVisual as PhoneApplicationFrame;
    root.GoBack();
});

如果你使用 root.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));将丢失实际页面并返回索引

对不起我的英语

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多