1

再会,

我正在尝试为(ObjectiveC)创建绑定

@interface GPUImageView : UIView <GPUImageInput>
{
    GPUImageRotationMode inputRotation;
}

通过在 ApiDefinitions.cs (MonoTouch) 中编写

[BaseType (typeof(UIView))]
interface GPUImageView : GPUImageInput{
    [Export ("initWithFrame:")]
    IntPtr Constructor(RectangleF frame);

    [Export ("autoresizingMask")]
    UIViewAutoresizing AutoResizingMask { get; set;}

    [Export ("addSubView:")]
    void AddSubView(UIView view);
}

当我打电话时我得到一个“InvalidCastException”

GPUImage.GPUImageView filterView = (GPUImage.GPUImageView)this.View;

我可以创建一个使用反射的构造函数。但这真的是正确的方法吗?

干杯!

4

1 回答 1

1

正如 Rolf Bjarne Kvinge 指出的那样,解决方案是将 Interface Builder 中的类类型更改为 GPUImageView。这将创建一个应该继承自 GPImageView 的类,而后者又继承自 UIView。也不需要绑定 AddSubview。

于 2012-06-05T17:52:46.577 回答