ios - User adding rows/sections to static cells in Table View Controller -


i'd create screen similar "new contact" screen of iphone contacts app. there little green '+' signs next "add phone", "add email", etc. when user clicks on these, new rows (or in case of "add address", suppose new sections) created.

how can create similar behaviour in table view controller?

thanks, daniel

here example how add lines tableview:

// holding data nsmutablearray* data;  - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return [data count]; }  - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     return [[data objectatindex:section] count]; }  - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {      //if want add section 1 row:     nsmutablearray *row = [[nsmutablearray alloc] init];     [row addobject:@"some text"];     [data addobject:row];     [tableview reloaddata];      //if want add row in selected section:     row = [data objectatindex:indexpath.section];     [row addobject:@"some text"];     [tableview reloaddata]; }  - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath*)indexpath {     static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier forindexpath:indexpath];      cell.textlabel.text = [[data objectatindex:indexpath.section] objectatindex:indexpath.row];      return cell; } 

there should new row in tableview. next step replace "some text" our own data.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -