当我从大小函数内部调用Greet时,DisplayAlert会按预期显示警告但是当在事件之后从委托调用它时,它将使用正确的名称(Greet Has Called)记录到输出但DisplayAlert不显示.
public class CustomPage : ContentPage { ... protected override void OnValidSizeAllocated(double width,double height) { ... Greet("Test"); app.FB.GetName(); app.FB.NameRecieved += (s,e) => { Greet(e.Name); }; } public void Greet(string name) { Utils.Log("Hey " + name); DisplayAlert("Hey " + name,"Welcome","OK"); } }
上面的代码输出“嘿测试”,然后出现一个警告,说“嘿测试,欢迎”,然后输出“嘿Leo”(这是正确的,因为这是来自Facebook帐户的名称)然后没有警报显示.