I am attempting a simple segue in my app using xamarin studio. I used the storyboard to initiate the segue using the "present modally" function, but every time I click the button to perform the segue in a simulator I receive the following error:
Failed to marshal the Objective-C object 0x7f8018511770 (type: loginViewController). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'iOSApp.loginViewController' does not have a constructor that takes one IntPtr argument).
Any idea as to what may be causing the problem? I have attached a screenshot of my main.storyboard file as well.
The following code snippets are my ViewController.cs
files and loginViewController.cs
codes
using System;
using UIKit;
namespace iOSApp
{
public partial class ViewController : UIViewController
{
protected ViewController(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
}
}
and
using System;
using UIKit;
namespace iOSApp
{
public partial class loginViewController : UIViewController
{
public loginViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
// Release any cached data, images, etc that aren't in use.
}
}
}
In your LoginViewController
class ensure that you have the following constructor so it can be inflated from the storyboard:
protected YourClassNameViewController(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
If your class name is loginViewController
, then your class will look something like:
protected partial class loginViewController : UIViewController
{
public loginViewController(IntPtr handle) : base (handle)
{
// Note: this .ctor should not contain any initialization logic.
}
~~~~ rest of class
}