2012-06-05 136 views
1

好日子,溯造型一类无需添加一个新的构造

我试图创建由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); 
} 
写这个的(的ObjectiveC)

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

绑定

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

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

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

干杯!

+0

'this.View'是如何创建的? –

+0

这是我的viewController中的标准视图。 – Bagaboo

+0

如果您使用Interface Builder,则需要将Interface Builder中的视图类型更改为GPUImageView。 –

回答

1

正如Rolf Bjarne Kvinge指出的,解决方案是将Interface Builder中的类类型更改为GPUImageView。这创建了一个应该从继承自UIView的GPImageView继承的类。无需绑定AddSubview。