Skip to content

Instantly share code, notes, and snippets.

@mwise
Created July 5, 2014 14:36
Show Gist options
  • Save mwise/bab66be2682c1c9792f9 to your computer and use it in GitHub Desktop.
Save mwise/bab66be2682c1c9792f9 to your computer and use it in GitHub Desktop.
searchable_table.rb
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