ios - Why is my tableview not scrolling to the requested indexPath? -
i have tableview in view , works fine, each custom cell (todolistcell) has text field allow users edit, updating data. , well, problem occurs whenever trying scroll cell going hidden keyboard.
note: adjust size of table using nsnotificationcenter observer methods apple documentation recommends , know not problem.
- (void)scrolltoselectedcell { nsindexpath *currentindexpath = [nsindexpath indexpathforitem:0 insection:0]; while (currentindexpath.row < self.todos.count) { todolistcell *cell = (todolistcell *)[self.table cellforrowatindexpath:currentindexpath]; if (cell.titlefield.isediting == yes) { [self.table scrolltorowatindexpath:currentindexpath atscrollposition:uitableviewscrollpositionmiddle animated:yes]; break; } currentindexpath = [nsindexpath indexpathforitem:currentindexpath.row + 1 insection:0]; } }
any idea why not scroll cell not on screen?
thanks,
ben
just guess, because
todolistcell *cell = (todolistcell *)[self.table cellforrowatindexpath:currentindexpath];
is returning nil
causing cell.titlefield.isediting == yes
fail. scroll command never called. table views hold onto visible cells, if you've resized table view such cell being edited no longer visible, you're going going nil
back. need determine index path of cell being edited before resizing table.
Comments
Post a Comment