iOS:在 UITableViewCell 中显示所需 UITextField 的正确方法
我尝试过谷歌并查看了 iOS 人机界面指南,但似乎找不到任何关于显示需要自定义 Grouped UITableViewCell 内的 UITextField 的最佳实践。
有什么建议或者有人见过其他应用程序是如何做到这一点的吗?我基本上是动态创建一个表单,并且需要让用户知道必须填写某些字段的某种方式。
I have tried google and looked at the iOS Human Interface Guidelines but cannot seem to find anything on the best practices for displaying that a UITextField inside of a custom Grouped UITableViewCell is required.
Is there any recommendations or has anyone seen how other applications do it? I am basically creating a form dynamically and need to let the user know some way that certain fields MUST be filled out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般来说,星号是个好主意。如果您使用占位符文本,那么当用户填写该框时,他们将无法再看到它——因此填写的表单不会告诉您哪些字段是必填字段或不是。
我会在
UITextField
旁边放置一个小的UILabel
,并让该UILabel
包含一个星号,可能是红色的。或者,如果大多数字段都是必填字段,那么您可以在可选字段中使用占位符文本,即 (可选)
此外,您还可以创建一个方法来检查所有必填字段是否已填写。如果不是,请禁用“继续”按钮。如果是,则启用“继续”按钮。通过 UITextFieldDelegate 方法调用此方法。
Generally, an asterisk is a good idea. If you use placeholder text, then when the user fills in the box, they can't see it anymore --- so a filled-in form wouldn't tell you which fields were mandatory or not.
I would put a small
UILabel
next to theUITextField
, and have thatUILabel
contain an asterisk, probably in red.Or, if most of the fields are required, then you can use placeholder text in the optional fields, that says (optional)
Also, you can create a method that checks if all the required fields are completed. If they aren't, then disable the "Continue" button. If they are, then enable the "Continue" button. Call this method via a
UITextFieldDelegate
method.您可以使用 UITextField 占位符属性来显示文本“名称为必填项”。这将向用户表明该字段是必填字段并且必须填写。
You can use the UITextField placeholder property to display the text "Name is required". This will indicate to the user that the field is required and must be filled.