I am working on a Xamarin IOS/monotouch project. I have been stuck with this error since some time. These are the lines of code
var prfc = this.Storyboard.InstantiateViewController ("testController") as testController;
if (prfc != null) {
this.PresentViewController(prfc,false,null);}
I tried renaming viewcontroller, cleaning and building solution, deleting viewcontroller and adding a new one with another name I have ensured that all spellings are correct, i have same Viewcontroller name, StoryBoardID, and Restoration ID. This is how I have registered my viewcontroller in Designer partial class
[Register ("testController")]
partial class testController
Here is my appdelegate.cs code `[Register ("AppDelegate")] public partial class AppDelegate : UIApplicationDelegate { // class-level declarations UIWindow window; public static UIStoryboard Storyboard = UIStoryboard.FromName ("MainStoryboard", null); public static UIViewController initialViewController; public override UIWindow Window { get; set; }
`[Register ("AppDelegate")] public partial class AppDelegate : UIApplicationDelegate { // class-level declarations UIWindow window; public static UIStoryboard Storyboard = UIStoryboard.FromName ("MainStoryboard", null); public static UIViewController initialViewController; public override UIWindow Window { get; set; }
// This method is invoked when the application is about to move from active to inactive state.
// OpenGL applications should use this method to pause.
public override void OnResignActivation (UIApplication application)
{
}
// This method should be used to release shared resources and it should store the application state.
// If your application supports background exection this method is called instead of WillTerminate
// when the user quits.
public override void DidEnterBackground (UIApplication application)
{
}
// This method is called as part of the transiton from background to active state.
public override void WillEnterForeground (UIApplication application)
{
}
// This method is called when the application is about to terminate. Save data, if needed.
public override void WillTerminate (UIApplication application)
{
}
public override void FinishedLaunching (UIApplication application)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
initialViewController = Storyboard.InstantiateInitialViewController () as UIViewController;
window.RootViewController = initialViewController;
window.MakeKeyAndVisible ();
return ;
}
}`
I have tried out every possibility but can't fix this. This error is occuring for every new viewcontroller that I add to Storyboard. I am getting a null when I call InstantiateViewController. I have tried cleaning and rebuilding. It works on simulator, but not on device