Asynchronous Monotouch异步和显示活动指示器

Asynchronous Monotouch异步和显示活动指示器,asynchronous,uiviewcontroller,xamarin.ios,uiactivityindicatorview,Asynchronous,Uiviewcontroller,Xamarin.ios,Uiactivityindicatorview,我在UIViewController中的viewdidload方法中调用了以下代码 window = new UIWindow (UIScreen.MainScreen.Bounds); window.RootViewController = tabController; 在appdelegate中,我有一个UINavigationController,该控制器用上述控制器实例化,反过来,UINavigationController被放置在UITabViewController

我在UIViewController中的viewdidload方法中调用了以下代码

window = new UIWindow (UIScreen.MainScreen.Bounds);
        window.RootViewController = tabController;
在appdelegate中,我有一个UINavigationController,该控制器用上述控制器实例化,反过来,UINavigationController被放置在UITabViewController中,而UITabViewController又被指定为rootviewcontroller

window = new UIWindow (UIScreen.MainScreen.Bounds);
        window.RootViewController = tabController;
在控制器内部,我正在进行异步web调用以获取数据以填充表,如果我使用加载视图代码显示活动指示器,我将在monotouch中收到以下警告

应用程序预计在应用程序启动结束时会有一个根视图控制器

public class LoadingView : UIAlertView
{
    private UIActivityIndicatorView _activityView;

    public void ShowActivity (string title)
    {
        Title = title;

        this.Show();
        // Spinner - add after Show() or we have no Bounds.
        _activityView = new UIActivityIndicatorView (UIActivityIndicatorViewStyle.WhiteLarge);
        _activityView.Frame = new RectangleF ((Bounds.Width / 2) - 15, Bounds.Height - 50, 30, 30);
        _activityView.StartAnimating ();
        AddSubview (_activityView);

    }

    public void Hide ()
    {
        DismissWithClickedButtonIndex (0, true);
    }
}
任何指点都将受到感激

编辑:我已经在设置根视图控制器

window = new UIWindow (UIScreen.MainScreen.Bounds);
        window.RootViewController = tabController;
完整的appDelegate代码:

public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            // create a new window instance based on the screen size
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            tabController = new UITabBarController();

            jobsNavigationController = new UINavigationController(new JobsController());
            jobsNavigationController.NavigationBar.BarStyle = UIBarStyle.Black;
            jobsNavigationController.TabBarItem.Image = UIImage.FromFile("Images/briefcase.png");
            jobsNavigationController.TabBarItem.Title = "Current Positions";

            myAccountNavigationController = new UINavigationController(new LoginDialogViewController());
            myAccountNavigationController.NavigationBar.BarStyle = UIBarStyle.Black;
            myAccountNavigationController.TabBarItem.Image = UIImage.FromFile("images/man.png");
            myAccountNavigationController.TabBarItem.Title = "My Account";

            tabController.SetViewControllers(new UIViewController[] { jobsNavigationController,myAccountNavigationController,new SettingsDialogViewController()},false);

            window.RootViewController = tabController;

            // make the window visible
            window.MakeKeyAndVisible (); 
            return true;
        }
要避免此警告(在iOS5中)并保持iOS 4.x兼容性,可以在
FinishedLaunching
方法中执行以下操作:

if (UIDevice.CurrentDevice.CheckSystemVersion (5, 0))
    window.RootViewController = navigation; 
else
    window.AddSubview (navigation.View);
查找更完整的示例。

window.AddSubview(tabcontroller.view)


修复了这个问题,奇怪的是我不再设置rootviewcontroller。

你能在AppDelegate中显示FinishedLaunching方法吗?这就是通常抛出错误的地方。在iOS 5中,需要分配RootViewController,例如:window.RootViewController=MyTabBarController;现在看一看,已经按照你的建议做了。请发布完整的FinishedLaunching()。我最好的猜测是您的tabConroller为NULL。我一到家就会这样做,尽管tabController被实例化为成员级变量。要消除该错误,我需要做的就是删除对Loadingview.ShowActivity.window.RootViewController的调用,因为它在iOS4中已经可用,所以这不是问题所在。@Krumelur IIRC Apple仅在iOS5+上显示该警告(问题),但您是对的,它从iOS4开始就可用,因此您可以简单地分配它,而无需条件。