Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想限制文本字段的长度,以便用户知道他可以输入多少个字符。但我在 iPhone 上找不到文本字段的此类属性。任何想法如何做到这一点?
以及当达到最大长度时如何从一个文本字段切换到另一个?(让用户轻松输入)
您可以查看 UITextFieldDelegate 协议,特别是 textField:shouldChangeCharactersInRange:replacementString:。您可以检查您的文本字段是否已达到其最大大小,如果是,则通过发送 becomeFirstResponder 移动到下一个适当的文本字段: