我在MonoTouch中有一个UIViewController,与.xib一起定义为iPad视图控制器。
如果我改变UIViewController以使用这样的动态类型:
public partial class CustomCount : UIViewController<tUnit> where tUnit : struct
{
private tUnit someVariable;
... (rest of class goes here) ...
然后,monoTouch似乎不再在该视图控制器的xCode项目中生成相应的.h和.m文件。
因此,我无法再访问任何UI插座(因为它们在.m文件中定义)
如果删除tTUnit
动态类型,一切正常。
where tUnit : struct
部分对MonoTouch没有任何影响。
有没有任何已知的解决方案,或者我应该为我所期望的每种类型创建我的班级的单独版本?
答案 0 :(得分:2)
是否需要struct
?否则你可以使用一个界面。
你可以这样做:
public partial class CustomCount : UIViewController
{
//Use a static method here
public static CustomCount Create(ISomeInterface yourVariable) { return new Customcount() { someVariable = yourVariable }; }
//Private Constructor
private CustomCount() { }
private ISomeInterface someVariable;
}
你可以将someVariable
作为公共财产或其他事件。