在iOS中实现表单的最佳实践是什么? [英] What are the best practices for implementing form in iOS

查看:181
本文介绍了在iOS中实现表单的最佳实践是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建几个屏幕表单,用于输入数据并发布到服务器。我还没有做过这样的事情,所以我只是想知道是否有任何最佳做法。目前,我只是放弃几个文本字段,收音机等,做一些手动输入验证,做一个输入数据到URL的汇编,然后提交到服务器。

我在考虑可用性,所以我认为我应该在用户解除键盘(辞职第一响应者)之后实现移到下一个文本字段。但是,如果所有的输入已经填满并且用户改变了一个字段的值,那么只需导航到提交按钮即可。所以,恕我直言,这可能是一个实践的形式实践的例子。

解决方案

我从实施表单中获得的一些经验:


  • 将输入和标签放在 UITableView (分组)的行中。这是苹果公司的做法和大多数用户习惯的方式。但要注意细胞的再利用,因为这可能会导致你的输入移动。换句话说,将引用保存在单独的 NSArray (或 NSDictionary )中,以确保它们不是在重用UITableViewCells时丢失。

  • 使用键盘返回键移动到下一个输入是个好主意。如果你只是跟踪你正在编辑的表格单元格,那么很容易,所以你可以使用它的NSIndexPath移动到下一个表格单元格。

    检查当用户进行修改时,即通过监听 UITextFieldTextDidChangeNotification textFieldShouldEndEditing:,您的表单有效性。如果表单有效,则允许用户在返回时使用或使用完成按钮(或类似)。 如果用户正在编辑最后一行形式,将键盘返回按钮类型更改为完成或类似。 在键盘上方显示输入附件视图(带有上一个/下一个/完成的工具栏)。特别是当你有更广泛的形式时,用户可能想要在输入之间来回切换。这是相当易于实施




希望有所帮助!


I need to create several screens-forms that would be used for entering data and posting to the server. I have not done that kind of stuff yet, so I'm just wondering are there any best practices for doing that. Currently, I would just drop several text fields, radios and etc, do some manual input validation, do an assembly of input data into URL and then do submission to the server.

I'm thinking about usability, so I think I should implement "move to next text field" after a user dismisses keyboard (resigns first responder). But if all the inputs are filled already and a user changes the value of one field then just navigate to submit button. So, IMHO that might be an example of practice for implementing a form. What practices do you apply?

解决方案

A few of my experiences from implementing forms:

  • Place inputs and labels in the rows of a UITableView (grouped). It's the way Apple does it and the way most users are used to. But be wary with the reuse of cells, as this may cause your inputs to move around otherwise. In other words, keep references to your inputs in a separate NSArray (or NSDictionary) to make sure they're not lost when the UITableViewCells are reused.

  • Using the keyboard return key to move to the next input is a good idea. It's easy to do if you just keep track of which table cell you're editing, so you can move on to the next one using its NSIndexPath.

  • Check your form validity when the user's made modifications, i.e. by listening to UITextFieldTextDidChangeNotification and in textFieldShouldEndEditing:. If the form's valid, allow the user to submit it on return or using a Done button (or similar).

  • If the user's editing the last row in the form, change the keyboard return button type to Done or similar.

  • UPDATE: Since posting this, it's also become quite common to show input accessory views (the toolbar with Prev/Next/Done) on top of the keyboard. In particular when you've got a more extensive form where users might want to go back and forth between inputs. And it's quite easy to implement.

Hope that helps!

这篇关于在iOS中实现表单的最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆