2010-12-03 61 views
2

我在iPad(iOS 4.2)的MonoTouch中有一个应用程序。我有一个主窗口显示一个按钮和一个导航栏。当我点击这个按钮时,我想显示另一个控件从web上加载一些数据。我instanciate UIAlertView并调用Show方法。比我称为新控件的数据加载,然后完成我提出新的控制。 我的问题是,在调用alert.Show()后没有显示任何内容,只有背景更改如预期。警报本身显示在我介绍新控制之后。 我的代码:MonoTouch UIAlertView不显示

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); 
} 
} 

回答

5

你不是GUI线程,这也许是为什么你得到奇怪的行为上呈现UIAlertView,请尝试:

InvokeOnMainThread(delegate{ 
    loadingDialog.Show(); 
}); 
0

用代码格式化的东西很糟糕。

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); 
     } 
    }