Sha256: 891edda96a552f0c21947496bdb55b2c6632d95025e9c11f5af95aa4c754dfd0
Contents?: true
Size: 1.8 KB
Versions: 1
Compression:
Stored size: 1.8 KB
Contents
module ProMotion::MotionTable module SearchableTable def makeSearchable(params={}) params[:frame] ||= CGRectMake(0, 0, 320, 44) params[:contentController] ||= self params[:delegate] ||= self params[:searchResultsDataSource] ||= self params[:searchResultsDelegate] ||= self searchBar = UISearchBar.alloc.initWithFrame(params[:frame]) if params[:searchBar] && params[:searchBar][:placeholder] searchBar.placeholder = params[:searchBar][:placeholder] end @contactsSearchDisplayController = UISearchDisplayController.alloc.initWithSearchBar(searchBar, contentsController: params[:contentController]) @contactsSearchDisplayController.delegate = params[:delegate] @contactsSearchDisplayController.searchResultsDataSource = params[:searchResultsDataSource] @contactsSearchDisplayController.searchResultsDelegate = params[:searchResultsDelegate] self.tableView.tableHeaderView = searchBar end def searchDisplayController(controller, shouldReloadTableForSearchString:searchString) @mt_table_view_groups = [] @original_data.each do |section| newSection = {} newSection[:cells] = [] section[:cells].each do |cell| if cell[:title].to_s.downcase.strip.include?(searchString.downcase.strip) newSection[:cells] << cell end end if newSection.count > 0 newSection[:title] = section[:title] @mt_table_view_groups << newSection end end true end def searchDisplayControllerWillEndSearch(controller) @mt_table_view_groups = @original_data.clone @original_data = nil end def searchDisplayControllerWillBeginSearch(controller) @original_data = @mt_table_view_groups.clone end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ProMotion-0.1.2 | lib/ProMotion/helpers/motion-table/1st/searchable_table.rb |