iOS Contact app style edit user information form - ios

I want to create a page where user can edit their information like the iOS Contact App. However, from my understanding, the UITableView does not offer that option. It only allows you to insert cell, delete cell, rearrange cell (Am I correct?). Is there an easy way to do this?
I solution I can think of is to create a new cell for each user info, but it would be very tedious and messy because I will have to create custom cell for each user info type. If I have 5 cell type, then there'll be 15 additional files(.m .h .xib) for me to create. Or I can create the prototype cell in storyboard, but I don't know now to prevent it from reusing the cell and losing my data in the process.

If it's for contact, you can try to use some of AddressBookUI framework built-in view, like the ABPersonViewController which allow to view and edit a contact.
https://developer.apple.com/library/ios/DOCUMENTATION/ContactData/Conceptual/AddressBookProgrammingGuideforiPhone/Chapters/UI_Controllers.html#//apple_ref/doc/uid/TP40007744-CH5-SW1
Otherwise, if you need a custom form, there is not built-in iOS control to do this.
Interface Builder can help you using static cells (if you can support subclassing UITableViewController) or via prototype cell for each type of field (date, string, toggle, ...).
Also, You can check some github project which try to solve this:
https://github.com/brunow/FormKit.m
https://github.com/B-Sides/ELCTextFieldCell
https://www.cocoacontrols.com/search?utf8=✓&q=form
Hugues

Related

Adding a UIView based on a template in swift?

I've used UITableView before and like the way that the user can add a practically unlimited number of cells by entering information and the program uses a template. I'm wondering if there is a way to do this, but instead of using a table, using regular views or even buttons. For example, the user would tap a button, enter information, and return to the first ViewController and it would have a new view with the information in place of parts of a template that I designed.
Sorry if this is unclear. Basically I'm wondering if there is a way to make a table that is not as restrictive as a table, but uses several individual views in place of cells.
You can create re-usable views in the same way that you can create prototype cells.
Just right click in your project window, add new file and select User Interface > View. create it just like you would a prototype cell.
Then create a related class by adding a new swift file, link the two, create any outlets or actions you need and add any required logic.
Once you are done you can just load it wherever you need it, like so
self.headerView = NSBundle.mainBundle().loadNibNamed("HeaderView",owner:self,options:nil) as! HeaderView
You would likely need to pass in some required information, or setup the views frame or constraints.
I found a YouTube Video which should help guide you through the process. I've only skimmed through it so you may need to look around for a better one, but the general concept seems to be there.

how to add comments text in UITableViewCell?

i am new to social media App , i just want to know how to Add comments in textview and when user press done button the entered text should update it in UITableViewCell and if user again tries to comments that comment also to be added in Cell and i want to reuse the data as well can u suggest any sample code for this or any tutorial?
You can use dynamic layout.
Here is the project I use dynamic layout: https://github.com/khuong291/Yelp. Just download and have a look at it.
And whenever user want to comment more, you have to create a new label or textview and put that string in it.
Ideally you need to add your data in any collection type (Ideally Array) & Then you just need to reload the table to display added data.

making a profile page, with tableView and textField

im new in ios development and i want create a profile page with UITableView i tried Google, but i didn't find anything :( Assuming that i have 1 field (Name) on UITableView, when i click on "Edit" Button, i want the TabViewCell to became a UITextFields to let me edit the data. And then when i click the "Done" Button the UITextView became a TabViewCell again with new Value, All i can found as tutorial, is just how to delete, add or move a cell.
Does apple have an api for making editable forms in iOS?
No, there's no API specifically for creating editable forms, but UIKit certainly provides all the tools you'd need to create editable content of all kinds. Instead of relying on tutorials to show you the solution to every problem you need to learn how to use the API that's there to construct the user experience that you imagine. Until you do that, you won't be able to implement any original ideas.
Using a table is a reasonable way to create the form you want. Consider using a different type of cell when the user hits the Edit button. So, when Edit is tapped, reload the table content using the editable cell types instead of the normal ones. When they hit Done, record the changes and then reload again using the non-editable cell types.

Table View Design Issue

My app design required a page that display 'user information' and i currently have this setup using a simple table view in a View controller. Now, the tricky thing is I need to be able to provide functionality to the user to be able to edit these on the same same screen. So essentially when the user taps on a row in the table view, I want that little flashing text line at the end of the current text in the row so the user can edit what's currently present and I also want a save button to apear on the top when a user has started editing. The tricky part is, not all fields in my table view will be editable. So, I need certain fields to be editable and have the save button appear and certain fields not.
Can you tell me how would I go about modifying my existing design to implement this functionality? I would appreciate some code if you think you can show me how exactly I would go about doing things.
You would probably want to make some custom UITableViewCells. You can fill a tableview with all sorts of different cells which are different sizes and looks different, all at the same time. I would suggest a custom UITableViewCell which will hold a UITextField as one of the subviews. On the cells which you don't want user interaction with the textfield, either make a new custom cell that uses a UILabel or just do textfield.userInteractionEnabled = NO. Look up some custom uitableviewCell tutorials to get you started and then use the approach that I suggested for your problem.

iphone/ipad how to handle lots of input fields?

I'm writing a app that contains quite a bit of input fields for collecting data.
and im wondering what are some good methods to display these kind of input fields, if there are too many to fit on a screen? so something like the add contact screen... where u can scroll down and there are fields there
my initial idea is to put them in a scroll view and then i can scroll through them, is there a tutorial to do this? it seems like the scroll view is more for dynamically displaying data like a text view, and not for static forms like i was describing.
if anyone has any different methods for doing this please post.
UITableview will match perfectly for what you need.
My friend wrote this which is a container view that automatically helps with moving fields out of the way of the keyboard - It will certainly save you some time if you don't want to use a UITableView:
https://github.com/mackross/GTKeyboardHelper
The other way as H2CO3 suggested is to use a UITableView. If it is a UITableViewController, then you get the moving out of the keyboards way automatically. You could build custom table view cells that are styled to have a prompt and a UITextField for input. You can also set the selectionStyle to UITableViewCellSelectionStyleNone to prevent these cells from highlighting when selected.
I think the third way is to do this with a UINavigationController (or a UIPageControl) and build a kind of wizard, where you go through various pages of related data. This might be the neatest way depending on how many fields you have and if you can group data into common sets (e.g. personal information, work information etc)
I had the same problem and found GTKeyboardHelper to be an easy way out.
After drag and drop the framework in your project, include the header file.
Download and open the example project, then drag the "Keyboard Helper" object from the objects section in the xib to the objects section in your project's interface builder.
Drag and drop all your views to be children of the "Keyboard Helper".

Resources