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 (将#修改为@)