从本机类MonoTouch的派生类 [英] Monotouch derived class from a native class

查看:124
本文介绍了从本机类MonoTouch的派生类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获得来自iCarousel机库编制了本机类(使用的这个例子)。
当使用生成的绑定一切完美:

I'm trying to derive a native class compiled from iCarousel native library ( used the LinkWith method described in this example ). When using the generated binding everything works perfectly:

iCarousel carousel = new iCarousel( new RectangleF(0, 0, 300, 300) );

但是,试图创建这个派生类中:

But when trying to create this derived class:

public class Carousel2 : iCarousel
{

    public Carousel2( RectangleF rect ) : base(rect)
    {
            Console.WriteLine("do something");
    }

}

和使用它是这样的:

Carousel2 carousel = new Carousel2( new RectangleF(0, 0, 300, 300) );

它编译但它只是停止工作,没有错误。它是我丢失的东西?

It compiles but it just stops working, with no error. Is it something I'm missing?

更新:我已经把Objective-C的头和ApiDefinition.cs源$ C ​​$ C在这里:
http://dantes-andreea.blogspot.com/2012/02/icarousel-monotouch-binding-$c$c.html

UPDATE: I've put the objective-c header and the ApiDefinition.cs source code here: http://dantes-andreea.blogspot.com/2012/02/icarousel-monotouch-binding-code.html

推荐答案

我认为你需要传递-e生成绑定时btouch,否则他们将不子类化。

I think you need to pass -e to btouch when generating the bindings, otherwise they will not be subclassable.

在默认情况下,因为他们是一个稍微慢一点btouch不会产生子类化的类型。

By default btouch does not generate subclassable types because they're a little bit slower.

更新

我错了,-e开关必须的的传递给btouch生成子类化绑定。不幸的是这个开关被无条件通过。一个错误报告已经立案。

I was wrong, the -e switch must not be passed to btouch to generate subclassable bindings. Unfortunately this switch is passed unconditionally. A bug report has been filed.

您或许可以解决它通过手动运行btouch命令MonoDevelop的已建成项目后(你建立绑定项目,C和,P的btouch命令行,并删除-e开关)。然后,你还必须运行任何后续步骤手动太多。

You can probably work around it by manually running the btouch command after MonoDevelop has built the project (you build the bindings project, c&p the btouch command line and remove the -e switch). Then you'll also have to run any subsequent steps manually too.

这篇关于从本机类MonoTouch的派生类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆