我有下面的代碼被稱爲鑑於我的UIViewController裏面viewDidLoad方法。MonoTouch的異步和展示活動指示燈
在appdelegate裏面我有一個UINavigationController,它用這個前面提到的控制器實例化,而UINavigationController放在UITabViewController裏面,而UITabViewController又被指定爲rootviewcontroller。
控制器裏面我做一個異步網絡調用來獲取數據來填充表,如果我使用加載視圖代碼來顯示一個活動的指標我得到的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;
}
,你能否告訴在AppDelegate中的FinishedLaunching方法?這是通常拋出錯誤的地方。在iOS 5中,您需要分配RootViewController,例如:window.RootViewController = MyTabBarController; – Anuj 2012-02-02 22:04:44
現在看看,已經在做你的建議。 – RubbleFord 2012-02-03 06:55:24
請張貼完整的FinishedLaunching()。我最好的猜測是你的tabConroller是NULL。 – Krumelur 2012-02-03 08:43:24