Add a row to UITableView for adding new item?

Posted by David.Chu.ca on Stack Overflow See other posts from Stack Overflow or by David.Chu.ca
Published on 2010-04-05T22:34:42Z Indexed on 2010/04/06 0:53 UTC
Read the original article Hit count: 1154

Filed under:

In order to provide UI for user to add new items to my table view, I would like to add a new row in my table at a specified location (last row for example) when the view is in edit mode (I have a edit button on the view's navigation bar right side). This new row will have a add button indicator on the left side and disclosure accessory arrow on the right. When the view is not in edit mode, this add row should not be displayed.

I am not sure if I should overwrite:

- (void)setEditing:(BOOL)editing animated:(BOOL)animated{...}

where I call the UITableView's method:

insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:
 (UITableViewRowAnimation)animation

to insert a new row?

My understanding is that this call may add a new row into the table view. The table view's data source is from CoreData storage. Not sure this may cause inconsistent numbers of data in the data store and table view? If it is OK and I have to manage rows in the table view, how can I add left add indicator and left disclosure arrow to the new row?

Another question is that if I can do it to insert a new row as Add row, should I remove it when the table view not in edit mode?

Just want to know if I am on the right track.

© Stack Overflow or respective owner

Related posts about iphone