MonoTouch UIAlertView无法显示

Sca*_*axx 2 xamarin.ios ipad

我有一个适用于iPad的MonoTouch应用程序(iOS 4.2).我有一个主窗口,显示一个按钮和一个导航栏.当我单击此按钮时,我想显示另一个控件从Web加载一些数据.我实例化UIAlertView并调用Show方法.比我为新控件调用数据加载,然后完成后我会显示新控件.我的问题是,在调用alert.Show()后,没有显示任何内容,只有背景按预期更改.在我呈现新控件后显示警报本身.我的代码:

    public void EnterCloudControl(TagCloudItem item)
    {
     using(UIAlertView loadingDialog = new UIAlertView("title", "message", null, "ok", null))
     {
  loadingDialog.Show();
  MyContentCloudController cc = new MyContentCloudController(ContentFrame, this);
  NavigationController.PushViewController(cc, true);
  cc.LoadData(item, DateTime.Now.AddDays(-30), null, string.Format("&Filter={0}{2};Equal;{1}", item.Field, item.Tag, 
  item.Field == "http://schemas.cid.biz/ps/nlp/entities" ? ",Label" : string.Empty), null);
  cc.SetupNavigationBar();
  loadingDialog.DismissWithClickedButtonIndex(0, true);
 }
}
Run Code Online (Sandbox Code Playgroud)

Luk*_*uke 5

你没有UIAlertView在GUI线程上展示,这可能是你为什么会遇到奇怪的行为,试试:

InvokeOnMainThread(delegate{
    loadingDialog.Show();
});
Run Code Online (Sandbox Code Playgroud)