在仍然使用模态页面的同时调用 PopModalAsync 后,Android 是否没有触发的解决方法。这是一个例子:
using System;
using Xamarin.Forms;
namespace XamarinForms
{
public class OnAppearingBug : ContentPage
{
Label label;
public OnAppearingBug ()
{
label = new Label {
Text = "Page"
};
Button button = new Button {
Text = "PushModal"
};
button.Clicked += (sender, e) => Navigation.PushModalAsync (new PopModalBug ());
Content = new StackLayout {
Children = { label, button }
};
}
protected override void OnAppearing(){
label.Text = "OnAppearing";
}
}
}
using System;
using Xamarin.Forms;
namespace XamarinForms
{
public class PopModalBug : ContentPage
{
public PopModalBug ()
{
Button button = new Button {
Text = "Pop Back"
};
//Bug: This will not trigger OnAppearing on Android
button.Clicked += (sender, e) => Navigation.PopModalAsync();
Content = new StackLayout {
Children = { button }
};
}
}
}