c# - 从继承自 UIVIewcontroller 的类继承(xamarin 和 c#)

标签 c# ios inheritance uiviewcontroller xamarin

我有一个继承自 UIViewController 的类:

public class A : UIViewController {

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

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

现在我有一个继承自 A 的 B 类:

public class B : A {

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

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

然后我创建一个 B 类实例:

B b = new b();

但是当屏幕出现时,它抛出

“无法找到选择器 setCancelButton:在 iOS.B 上”

所以问题是:我如何从子类访问继承自 UIViewController 的类(.xib 中的项目)的项目?

最佳答案

你必须在每个类上放置一个属性,以便在 Objective-C 上注册它们:

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

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

关于c# - 从继承自 UIVIewcontroller 的类继承(xamarin 和 c#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21284741/

相关文章:

C# 远程 MySQL - 用户访问被拒绝

c# - 为 Windows Phone 创建 PIN 查找框

iphone - iOS:将照片发布到 Facebook 和小 html 作为标题

iphone - 文件所有者和第一响应者之间的区别?

c++ - 使用模板的继承和转换未按预期工作

c# - 为什么 C# 不允许将泛型类型用作泛型类中的属性?

c# - Unity定期设置PlayerPrefs数据

ios - 不同设备宽度的 View 大小和对齐方式不同

objective-c - 属性声明 - ivar 和 getter 值不匹配

ruby-on-rails - Rails类继承,Mongoid返回数据失败