How would you go about forcing a UITableViewCell to scroll to the top if the tableview contains less than 10 or so cells? I support editing of Managed Object Contexts within my tableView cells while the tableview is in editing mode. Needless to say, if a cell is at the bottom of the tableview, it gets blocked by the keyboard when a user goes to edit the title or location of an event. I tried a solution like:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:NO];
if(_selectedIndex == indexPath.row){
_selectedIndex = -1;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
return;
}
if(_selectedIndex >= 0){
NSIndexPath *previous = [NSIndexPath indexPathForRow:_selectedIndex inSection:0];
_selectedIndex = indexPath.row;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:previous]
withRowAnimation:UITableViewRowAnimationFade];
}
_selectedIndex = indexPath.row;
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
[tableView setContentOffset:CGPointMake(0, [tableView rowHeight]*indexPath.row) animated:YES];
}
But this does not keep the tableview at the contentOffset. it will snap to the top and then snap back
Have you consider sliding the whole tableview up?
edit: I did find something that looks like it does what you’re looking for:
Code here.
This code shrinks the inset of the table view from the bottom, which then allows it display one of those lower cells without snapping back down.