简体   繁体   中英

How do I make an editable detail view on the iPhone with a grouped UITableView?

I want to make a grouped TableView similar to the Apple iPhone contacts application.

I need a lot of standard fields which can be edited, but I would only like them editable once the edit button in the navbar is clicked.

This has been bothering me forever that I could not find a good tutorial.

Thanks in advance.

This is not easy. I just built the same thing because there is nothing available from Apple. I ended up creating a single table cell with a UILabel and a UIView on it. The UILabel is for when the cell is in read mode, and the UIView is for editing. The UIView contains a number of UITextFields. These are the individual fields. I also had to implement drawing code to draw the lines between the fields. Then I had to come up with the code to pass in an address object, load it into the fields, format the text for the label, switch in and out of editing mode (with animation), and finally handling saving of changes and canceling. As yet it doesn't handle tapping the address type to select that from a popup list, but I have most of the code in place for the rest.

This could have been done using individual table view cells for each field. But then you can't select the whole thing the way it does in contacts and adding and deleting addresses becomes trickier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM