如何限制 iPhone 上文本字段中文本/数字的长度?
我想限制文本字段的长度,以便用户知道他可以输入多少个字符。 但我在iPhone上没有发现textfield有这样的属性。 有什么想法如何做到这一点?
当文本字段达到最大长度时,如何从一个文本字段切换到另一个文本字段? (让用户轻松打字)
I want to limit the length of a textfield, so that a user can know how many characters he can input. But I find no such attributes of textfield on iPhone. Any ideas how to do this?
And how to switch from one textfield to another when it reaches its max length? (to let users type easily)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查看 UITextFieldDelegate 协议,特别是 textField:shouldChangeCharactersInRange:replacementString:。 您可以检查您的文本字段是否已达到最大大小,如果是,则通过将其发送成为FirstResponder 移动到下一个适当的文本字段:
You might check out the UITextFieldDelegate protocol, specifically textField:shouldChangeCharactersInRange:replacementString:. You could check if your text field has reached it's maximum size, and if so move to the next appropriate text field by sending it becomeFirstResponder: