iphone - Add blank cell at end of UITable -


i'm trying add additional cell custom content last cell in tableview, without altering dictionary creates other content of table. think place add in cellforrowatindexpath rather adding 1 numberofrowsinsection, crashes if do.

i cellcount dictionary creates data table, in cellforrowatindexpath, have:

if (indexpath.row == cellcount) {         ... stuff goes here             return cell;                         }  

of course, never gets called. if if (indexpath.row == cellcount -1) overwrites last cell content.

i can work if add blank entry xml populating dictionary, that's ugly.

example code neat!

the problem here tableviews designed , accurately display contents of data-model , you've decided don't want that. you're fighting api.

the straight forward way put check in numberofrowsinsection such adds 1 row count when want display input row. in cellforrowatindexpath: need check if table view asking input row , return appropriate type of cell.

from ui design point, might want consider whether setup best. isn't standard setup. user going understand can edit last row of table? understand can't edit other rows? in ui tell them how works? user have scroll end of table every time want add data? how long can table grow? how displaying keyboard last row of table affect how table scrolls?

i think better design use footer view display text field such is visually distinct rest of table. programmatically simpler well. wouldn't have check if table asking last row every single time ask cell.

edit:

in thinking it, perhaps sectioned table simpler. put special row in own section (with or without header.) simplify handling of rows source dictionary because row count in section count of dictionary. likewise, check section attribute of indexpath know cell return row.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -