4
我有一个UITextField,我想使用ShouldChangeCharacters委托方法更改字符。但是,当我使用textField obj时,它说与UITextFieldChange不匹配... 我应该如何在Monotouch中执行此操作?如何在Monotouch中实现ShouldChangeCharacters?
我有一个UITextField,我想使用ShouldChangeCharacters委托方法更改字符。但是,当我使用textField obj时,它说与UITextFieldChange不匹配... 我应该如何在Monotouch中执行此操作?如何在Monotouch中实现ShouldChangeCharacters?
这里是迫使全部大写的例子:
textField.ShouldChangeCharacters = (textField, range, replacementString) =>
{
using (NSString original = new NSString(textField.Text), replace = new NSString(replacementString.ToUpper()))
{
textField.Text = original.Replace (range, replace);
}
return false;
};
我想应该是你所需要的。我倾向于总是使用Lambda表达式,这样你甚至不需要知道委托类型,参数类型等等。我让C#类型推断来完成工作。