0

I have a uitableview with multiple sections. I want to let user edit all rows of one section. The text is originally displayed with UILabels in section (Say section B). Is it possible to do something like this?

  1. Add an extra section (Say section C) with UITextView, and the same content as section B, But keep it hidden.
  2. Add an edit button somewhere so when user hits it, Section B hides, Section C shows up with two option buttons (Update, Cancel).
  3. Depending on what they choose, perform the action (say submit to server if Update is clicked, or Cancel and move to step 4 if cancel button is pressed)
  4. Hide the editable section C, Show section B (with new content if edited).

OR is there a better way to do this?

aVC
  • 2,254
  • 2
  • 24
  • 46
  • there are better ways to do it - look in apple's documentation and examples for lots of information on table view programming. you likely want to have a custom table cell that changes it's behavior when it's editable (use `UITextView` and change the editability of it, or swap between `UILabel` and `UITextView`) - - - there are standard ways of editing table views – bshirley May 29 '13 at 18:47
  • If you want to exclude a row (or all the rows in a section) from being editable, check out the table view data source method `- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath` – bshirley May 29 '13 at 18:48
  • @bshirley Thanks for the reply. Can you give a small example? When I search, its mostly about editing rows in teh sense deleting the rows, not about editing text inside a row. – aVC May 29 '13 at 19:26
  • google `uitableviewcell editable text` - it's not straightforward, no i won't create an example for you, give it a try, tell us what fails, we'll help you out - http://stackoverflow.com/questions/2803626/how-to-do-edit-in-place-in-a-uitableview - there are a lot of similar questions on stack overflow with variously useful responses – bshirley May 30 '13 at 16:30
  • there is a delegate (or data source?) method to tell what kind of "editing" to do when the cell is editable - default is "delete", you can return "none" to that and no button will show up (i think - not testing right now), you can at the same time make the cell text editable – bshirley May 30 '13 at 16:34
  • @bshirley Thanks for the comments. I read further, and I think i will go the novice way (As I am not well versed yet with all the inside tricks). I will call another view controller with textFields, which are by default editable. :) – aVC May 30 '13 at 20:53
  • that is definitely the way to go if you're not overly familiar with some of the intricacies - good luck. – bshirley May 31 '13 at 14:28

0 Answers0