Created
July 5, 2014 14:36
-
-
Save mwise/bab66be2682c1c9792f9 to your computer and use it in GitHub Desktop.
searchable_table.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RMExtensions | |
module SearchableTable | |
def setup_search_controller(opts) | |
$self = self | |
@search_bar = UISearchBar.alloc.initWithFrame( | |
CGRectMake(0, 0, frame.size.width, 44)) | |
@search_controller = UISearchDisplayController.alloc | |
.initWithSearchBar(@search_bar, contentsController: rmq.view_controller) | |
@search_controller.delegate = self | |
@search_controller.searchResultsDataSource = self | |
@search_controller.searchResultsDelegate = self | |
@search_controller.displaysSearchBarInNavigationBar = true | |
@search_opts = opts | |
end | |
def searchDisplayController(controller, | |
shouldReloadTableForSearchString: search_string) | |
if @search_opts[:action] && @search_opts[:action].respond_to?(:call) | |
@search_opts[:action].call(search_string) | |
end | |
!@search_opts[:async] | |
false | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment