Xamarin for iOS: All Controls null in initial view controller

1.9k Views Asked by At

I am developing a Storyboard application for iPhone with Xamarin.iOS. My App Delegate - finished Launching code looks as follows:

public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
    //Create our window
    Window = new UIWindow(UIScreen.MainScreen.Bounds) { TintColor = UIColor.White };

    //Register some services
    ServiceStorage.Register(() => Window);
    //Apply our UI theme
    Theme.Apply();

    //Load our storyboard and setup our UIWindow and first view controller
    storyboard = UIStoryboard.FromName("MainStoryboard", null);
    loginController = storyboard.InstantiateInitialViewController() as LoginViewController;
    Window.RootViewController = loginController;
    Window.MakeKeyAndVisible();

    return true;
}

So nothing very exciting here. I have a storyboard with my LoginViewController set as initial view controller.

So here is my problem: At first, for some reason, the override ViewDidLoad() method of my LoginViewController is being called 3 times. Second, all controls - I have text boxes and buttons, all designed from the storyboard designer and accessible via outlets - are Null during this ViewDidLoad method, so any time I want to set a text / image / ..., it raises an error.

Has anyone had such an error before? I have tried using a different view controller class and a different AppDelegate but nothing seems to work..

Your help would be greatly appreciated!

Thanks, Leonard

1

There are 1 best solutions below

0
On

So - I finally found the error... my LoginVC inherited from a BaseVC with an overridden constructor. An exception was raised every time this constructor had been called but Xamarin Studio was not friendly enough to tell me about this exception. Well, now it's working again.