title: Using the same View Controller for add, display, and edit
body: <p>I am working on an iOS app that uses a very common Core Data based tableview to display items and when one it selected, it shows a more detailed view, much like the Contacts app.  The detail view itself is a programmatically generated grouped table with a custom (nib-defined) view for a header that has a picture and a name.  Some of the cells in the table are custom cells that have a label name and a textbox value.  In "edit" mode, the editable table cells (and the name in the header) have .clearButtonMode set to UITextFieldViewModeAlways to show that they are editable.  </p>
  
  <p>I am currently using the same view controller to display the detailed information, edit the information, and add a new record to the original list.</p>
  
  <p>When a new item is being added, the view controller is created modally with a custom init overload that sets a flag in the view controller to indicate that it is adding the record.  This allows it to start in edit mode and if edit mode is left, the model view is dropped away.  The right menubar button is the usual Edit/Done, and the left one is a cancel button.  When an existing item is being edited, the left button (normal back button) is replaced with a cancel button.</p>
  
  <p>I am starting to have second thoughts as to whether or not having one view controller handle three different modes is the way to go.  There are few issues that I am not sure how to handle.</p>
  
  <p>1) How do I tell if edit mode is left by hitting "Done"?  Is there an action for it?  If cancel is hit, the action either dismisses itself (add mode) or restores the previous values leaves edit mode.  I suppose I could put a check in my setEditing override to handle it, but it seems that there should be a better way.</p>
  
  <p>2) When edit mode is entered and I set the editable text fields to UITextFieldViewModeAlways, is there a way to animate the appearance of the 'X' buttons so that they fade in with the editing indicators on the regular cells?</p>
  
  <p>Are there easy solutions to these problems or is my 3-in-1 view controller a bad idea?  It doesn't seem right to remake the same view for different modes, but having multiple modes for a view controller seems to be a bit of a hassle.</p>
  
  <p>jorj</p>