2017-04-06 30 views
1

我在使用xamarin工作室的应用程序中尝试简单的塞格。我用故事板开始使用“当前模态”功能SEGUE,但每次我按一下按钮,在我收到以下错误模拟器进行SEGUE:简单的塞格不在Xamarin中工作

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).

任何想法,以什么可能导致问题?我附上了我的main.storyboard文件的截图。

main.storyboard

下面的代码片段是我ViewController.cs文件和loginViewController.cs

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. 
     } 
    } 
} 

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. 
     } 


    } 
} 
+0

你'loginViewController' .actor是调用错误的基础上,将其更改为匹配我的回答的那些 – SushiHangover

+0

而对于将来,请不要添加代码的*截图*,将代码添加为文本。它是可搜索和容易审查的其他人,截图不是... ;-) – SushiHangover

+0

改变了问题,以反映建议以及代码(如上所示),但是,在模拟器中运行相同的问题相同的错误代码 – bananibau5

回答

1

在你LoginViewController类请确保您有以下构造函数,因此它可以从故事板充气:

protected YourClassNameViewController(IntPtr handle) : base(handle) 
{ 
    // Note: this .ctor should not contain any initialization logic. 
} 

如果你的类名是loginViewController,那么你的类看起来像:

protected partial class loginViewController : UIViewController 
{ 
    public loginViewController(IntPtr handle) : base (handle) 
    { 
     // Note: this .ctor should not contain any initialization logic. 
    } 

    ~~~~ rest of class 
} 
+0

仍然会导致相同的错误,我将编辑该问题以包含“ViewController.cs”和“loginViewController.cs”的屏幕截图 – bananibau5