objective-c - Monotouch Objective-C 绑定(bind)

标签 objective-c ios xamarin.ios

我在我们的项目中使用单声道绑定(bind)包含了“Cocoa Controls”中的一些控件,它们都工作正常,除了有一个我无法工作,我希望有人能发现一个明显的错误。

这是 Objective-C header

typedef enum {
kWTShort = 1,
kWTLong = 5
} WToastLength;

@interface WToast : UIView

+ (void)showWithText:(NSString *)text;
+ (void)showWithImage:(UIImage *)image;


+ (void)showWithText:(NSString *)text length:(WToastLength)length textColor:(UIColor *)    textColor backgroundColor:(UIColor *) backGroundColor;
+ (void)showWithImage:(UIImage *)image length:(WToastLength)length;



@end

这是 Mono ApiDefinition

[BaseType (typeof(UIView))]
interface WToast
{
      [Export("showWithText:")]
       void ShowText(String text);


    [Export("showWithText:length:textColor:backgroundColor:")]
    void ShowText(string text,ToastLenght lenght,UIColor textColor,UIColor   backgroundColor);
}

注意我没有包含枚举 ToastLength

对象以任何方式实例化,但当我调用 ShowText 时,程序找不到选择器 [WToast showWithText:]

希望有人能帮忙

问候克里斯蒂安·斯托尔·安德森

最佳答案

我想我只需要暂时离开代码一段时间。

答案是我有点厚

您会注意到 objective-c 函数是

+ (void)showWithText:(NSString *)text;

不是

- (void)showWithText:(NSString *)text;

Mono 定义应该是

[Static,Export("showWithText:")]
   void ShowText(String text);

不是

[Export("showWithText:")]
   void ShowText(String text);

谢谢大家

关于objective-c - Monotouch Objective-C 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13081288/

相关文章:

ios - 如何在顶点/片段着色器( Metal )中使用 3x3 2D 变换

c# - Monotouch 在非可空对象上因 NullReferenceException 而崩溃

ios - 更新 xCode/Xamarin 后,构建时出现 MT5306 错误

objective-c - Swift 中的外部变量

ios - 将 NSString 转换为整数

objective-c - 跟踪 NSPopover 的 subview 中是否存在 mousedown/up

objective-c - 索引到数组字典时出现无法识别的选择器错误

ios - 移除 UIWebView 的内部缓存

ios - 我可以在 UITextField 中有多个 leftOverlay 项目或同时有 2 个独立的文本吗?

ios - Mono 框架或 Mono 运行时是 Xamarin IOS ipa 包的一部分吗?