Inherit from a class that inherit from a UIVIewcontroller (xamarin and c#)

I have a class that inherits from UIViewController:

public class A : UIViewController {

  public A():base("A",null){
      //implementation
  }

  //Also it has the ViewDidLoad() and DidReceiveMemoryWarning(), etc.
}

Now i have a class B inheriting from A:

public class B : A {

  public A():base(){
      //implementation
  }

  //Also it has the ViewDidLoad() and DidReceiveMemoryWarning(), etc.
}

Then i create a B class instance:

B b = new b();

But when the screen appears, it throws

"Failed to find selector setCancelButton: on iOS.B"

So the question is: how can i access items on a class inheriting from UIViewController (item in .xib) from a child class?

Upvotes: 0

Views: 827

Answers (1)

Alexandre Marcondes
Alexandre Marcondes

Reputation: 5969

You have to put an Attribute on each class registering them on Objective-C:

[Register("A")]
public class A : UIViewController { }

[Register("B")]
public class B : A { }

Upvotes: 1

Related Questions