具有动态类型的MonoTouch UIView控制器



我在MonoTouch中有一个UIViewController,与.xib一起定义为iPad View Controller。

如果我将 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没有影响。

是否有任何已知的解决方案,或者我应该为我期望的每种类型创建我的类的单独版本?

是否需要成为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变成公共财产或其他东西。

最新更新