2010-12-03 84 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); 
     } 
    }