Search code examples
iphonecontactsediting

Editing a view in the iPhone like in Contacts app


In Contacts application when you click on "Edit" button on the right side of the navbar, view will dynamically change it self in order to allow user edit various stuff.

Besides other cool animated stuff that is going on, what I am really interested in though is the bottom "Delete Contact" button which appears when in edit mode and disappears when done or cancel is tapped.

How do you implement this kind of stuff? Thanks.

P.S.: related questions Create an Edit view similar to Contacts App and How is iPhone Contact app's detail View implemented won't cut it.


Solution

  • You need to keep track of if you are in editing mode or not with a BOOL. Then when the edit button is pressed toggle the state.

    For a delete button what you can do is have it in your view but hidden until the user is editing, and then when done editing hide it again. For animation change the frame and alpha for fading however you like in an UIView animation block when the editing BOOL changes.