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#類型推斷來完成工作。