开发者

What are the best practices for implementing form in iOS

开发者 https://www.devze.com 2023-03-30 18:36 出处:网络
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 d

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 an开发者_开发问答d 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!


in my application there are also several forms and i have used all field manually and for validation i created validation function for that .we have to pass this value and check it .if your forms have same field than you can create UiView for that and used that view in all screen. but i will be generted problem at checking and validation time..

so it is better way to do manually drag and drop all field and make common function for validation. for ResignFirstResponder you have to check all field that no one field is emplty than you can redirect to next page .i have no idea any inbuilt functionality for that .

i hope this will help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消