gpt4 book ai didi

c# - Xamarin.iOS Objective-C 绑定(bind)错误

转载 作者:行者123 更新时间:2023-11-29 10:51:17 24 4
gpt4 key购买 nike

我正在尝试绑定(bind):https://www.cocoacontrols.com/controls/tsvalidatedtextfield用于 Xamarin.iOS。

到目前为止,我已经使用 Objective-C 代码编译了一个静态库,并使用 Objective-Sharpie 生成了 API 定义。

对于其中两个属性,我收到了一个错误:

Error CS0246: The type or namespace name `NSRegularExpression' could not be found. Are you missing an assembly reference? (CS0246) (TSValidatedTextField)

Error CS0246: The type or namespace name `ValidationBlock' could not be found. Are you missing an assembly reference? (CS0246) (TSValidatedTextField)

没有任何意义。据我所知,NSRegularExpression 是我导入的 Foundation 框架的一部分(using MonoTouch.Foundation)。

我将如何修复这些错误?如果这两个属性被注释掉,绑定(bind)就会编译。

如有任何帮助,我们将不胜感激。

谢谢你们。

using System;
using System.Drawing;
using MonoTouch.ObjCRuntime;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace TSValidatedTextField
{

public enum ValidationResult {
Passed = 0,
Failed,
ueTooShortToValidate
}

[BaseType (typeof (UITextField))]
public partial interface TSValidatedTextField {

[Export ("regexpPattern")]
string RegexpPattern { get; set; }

[Export ("regexp")]
NSRegularExpression Regexp { get; set; } //ERROR

[Export ("isValid")]
bool IsValid { get; }

[Export ("regexpValidColor")]
UIColor RegexpValidColor { get; set; }

[Export ("regexpInvalidColor")]
UIColor RegexpInvalidColor { get; set; }

[Export ("validatedFieldBlock", ArgumentSemantic.Copy)]
ValidationBlock ValidatedFieldBlock { get; set; } //ERROR

[Export ("validWhenType")]
bool ValidWhenType { [Bind ("isValidWhenType")] get; set; }

[Export ("looksForManyOccurences")]
bool LooksForManyOccurences { [Bind ("isLooksForManyOccurences")] get; set; }

[Export ("occurencesSeparators")]
NSObject [] OccurencesSeparators { get; set; }

[Export ("minimalNumberOfCharactersToStartValidation")]
uint MinimalNumberOfCharactersToStartValidation { get; set; }
}

}

最佳答案

NSRegularExpressionValidationBlock不属于 Xamarin.iOS .

这并不意味着您被困在那里。就像你绑定(bind)TSValidatedTextField一样,你可以自己绑定(bind)它们。

完成后,最好标记 NSRegularExpression Regexp { get; set; }[Internal]并编写一些自定义代码来公开 .NET System.Text.RegularExpressions.Regex , 在 C# 中使用起来更自然。

关于c# - Xamarin.iOS Objective-C 绑定(bind)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20356390/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com