Set the maximum character length of a UITextField

前端 未结 30 1656
难免孤独
难免孤独 2020-11-22 02:27

How can I set the maximum amount of characters in a UITextField on the iPhone SDK when I load up a UIView?

30条回答
  •  名媛妹妹
    2020-11-22 03:05

    For Xamarin:

    YourTextField.ShouldChangeCharacters = 
    delegate(UITextField textField, NSRange range, string replacementString)
            {
                return (range.Location + replacementString.Length) <= 4; // MaxLength == 4
            };
    

提交回复
热议问题