开发者

MonoTouch UIAlertView not displaying

开发者 https://www.devze.com 2023-01-28 21:14 出处:网络
I have an app in MonoTouch for iPad (iOS 4.2). I have a main window displaying a button and a navigation bar. When I click this button I want to show another control loading some data from web. I inst

I have an app in MonoTouch for iPad (iOS 4.2). I have a main window displaying a button and a navigation bar. When I click this button I want to show another control loading some data from web. I instanciate UIAlertView and call Show method. Than I call loading of data for the new control and after that is done I present the new control. My problem is that after calling alert.Show() nothing is shown only the background changes as expected. The alert itself is displayed AFTER I present the new cont开发者_StackOverflowrol. My code:

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


You're not presenting the UIAlertView on the GUI thread, which is maybe why you're getting strange behaviour, try:

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


Sry something bad with code formatting.

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

精彩评论

暂无评论...
验证码 换一张
取 消