From 7b2ea668c5d405edc0ed44fac8bfc6e307ff361c Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Tue, 18 Jun 2013 16:49:06 -0400 Subject: [PATCH] Scroll the tableview all the way to the top when there's a search field and the table index begins with "{search}". Fixes #159 on MASTER branch. --- lib/ProMotion/screens/_tables/_table.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/ProMotion/screens/_tables/_table.rb b/lib/ProMotion/screens/_tables/_table.rb index afee3e0..08b9166 100644 --- a/lib/ProMotion/screens/_tables/_table.rb +++ b/lib/ProMotion/screens/_tables/_table.rb @@ -139,6 +139,17 @@ module ProMotion end end + def tableView(tableView, sectionForSectionIndexTitle:title, atIndex:index) + return index unless ["{search}", UITableViewIndexSearch].include?(self.table_data_index[0]) + + if index == 0 + tableView.setContentOffset(CGPointZero, animated:false) + NSNotFound + else + index-1 + end + end + def deleteRowsAtIndexPaths(indexPaths, withRowAnimation:animation) PM.logger.warn "ProMotion expects you to use 'delete_cell(index_paths, animation)'' instead of 'deleteRowsAtIndexPaths(indexPaths, withRowAnimation:animation)'." delete_cell(indexPaths, animation)