如何在Monotouch中绑定属性块

3

我正在学习如何将Objective-C绑定到Monotouch,但是遇到一个属性是块的问题。

@property (nonatomic, copy) void (^onLongPress)(UIView*, NSInteger);

我现在有这个。
delegate void onLongPress (UIView view, int index);
[Export ("onLongPress")]
void onLongPress() {  set;  }
1个回答

5

如何绑定块的文档在这里http://docs.xamarin.com/guides/ios/advanced_topics/binding_objective-c_libraries,位置在3.10。

但是你的代码展示了一个块属性,而不是接受一个属性的函数。

在你的情况下,我会像这样绑定它:

//ApiDefinition.cs
delegate void OnLongPress (UIView view, int index)

[Export("onLongPress")]
OnLongPress OnLongPress { set;}

这应该能够正常工作,但由于我从未遇到过这种情况,所以我对您的结果很感兴趣。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接