微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Xamarin.Android在页面之间导航时出现问题

如何解决Xamarin.Android在页面之间导航时出现问题

我的跨平台应用程序中有一个错误我有一个带有文档(文件夹)列表的页面,当我单击其中一个时,我有一些按钮可以添加一些照片(将文件添加到文档文件夹中)并将其发送到url。 因此,执行流程如下:

DocumentList-> DocumentEditor-> AddPhotos

在DocumentEditor中,如前所述,我可以通过client.postAsync(String Url,MultipartFormDataContent)将文档(和相关照片)发送到url。在此操作过程中我没有任何问题,但是当我按下导航栏中的“后退”按钮时。

我回到上一页(DocumentList),但是标题被剪切掉了,如果我想选择另一个文档,它会打开一个黑色的DocumentEditor页面

如果我不发送文档,则返回按钮没有任何问题,因此client.postAsync肯定存在问题。

有什么想法吗?

一些图片

postAsync之前的DocumentList:

enter image description here

postAsync之前的DocumentEditor:

enter image description here

按下postAsync和后退按钮后的

DocumentList(注意标题):

enter image description here

在上一个图像中选择文档后,使用DocumentEditor:

enter image description here

一些代码

在DocumentList中单击处理程序:

private async void TapGestureRecognizer_Tapped(object sender,EventArgs e)
    {
        Grid Cell = ((Grid)sender);
        String DirName = Cell.FindByName<Label>("DirName").Text;
        await Navigation.PushAsync(new DocumentEditor(DirName,Type));
    }

SendDocument按钮处理程序:

private async void InviaDocumento_Clicked(object sender,EventArgs e)
    {

        bool response await displayAlert("Invio","Vuoi davvero inviare il documento?","Si","No");

        if (response)
        {
            String url = some codes...
            ...
            MultipartFormDataContent multiContent = new MultipartFormDataContent();
            ...someCodes to populate multiContent...
            HttpClient client = new HttpClient();

            client.Timeout = TimeSpan.FromMinutes(2);

            HttpResponseMessage response2 = await client.PostAsync(url,multiContent);
            if (response2.StatusCode == HttpStatusCode.OK)
                {
                    await displayAlert("Upload","Upload completato con successo!","Ok");
                    //await Navigation.PopToRootAsync();
                }
                else
                {
                    string error = await response2.Content.ReadAsstringAsync();
                    await displayAlert("Errore","Si è verificato un errore durante l'upload: " + error,"Ok");
                }
         }
  }

编辑:

在ios上运行良好,在android上,即使使用执行Navigation.PopAsync()的按钮,此问题仍然存在。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。