How do I combine custom tableView search tools with a UISearchDisplayController? - iphone

I have a UITableView with a searchbar. I have a separate page (accessed via a tabBarController) of search tools that can query the data in a number of ways.
The difficulty I'm having is that when I search the data using the custom search tools, I'm filtering the actual tableView, not the UISearchDisplayController's searchResultsTableView.
I would like my custom query tools to effect the searchResultsTableView, but I can not find a way to access it. Also, when I return to the table after using the search tools, the original table is displayed, how can I display the searchResultsTableView?
Any ideas?
Thanks!

How are you populating the searchResultsTableView?
It might be a good idea to keep a separate dataset (maybe an NSArray) for that. When searching begins, matching items would get added to that dataset that, in turn, would be used to populate the searchResultsTableView.
That way, it would be a matter of filtering that specific dataset instead of the original one when using those custom search tools.
As for showing the searchResultsTableView when returning to the view, it depends on what is actually done when moving away from that view. Usual strategies are using setActive:YES on your UISearchDisplayController or storing the search string somewhere and calling setText:SEARCH_STRING on UISearchDisplayController's search bar after returning and retrieving that string.

Related

Autocomplete in swift with select item and pass object

I have seen many examples and tutorials about setting up autocomplete in swift. Mostly related to the search bar. But they do not include how to select the item in the drop-down and close the table view. Once you select the item how do you get access to the entire object. Also most data is coming from REST based API. Finally the search autocomplete should be incorporated with the existing view components.
Looking for examples or tutorials that address
adding search autocomplete to existing view
drop down data based on REST API. search term passed to API. Data includes entire object, not just name.
select item from drop-down and get entire object
hide table components and if necessary hide search components.

ios UITableView - functioning like a dropdown list

Requirement : implementing a drowdown functionality in an UIView
The known way is using a UIWebView.
My Q is can this be done via a TableView?
Is there any way which lets me select a section(just like selecting a row), so that I can implement a hide/show cells of a section when that particular section is selected?
Don't know if I am understanding you correctly, but it seems to me that what you want can be done like this:
have a UITableView with several sections;
each section has got just one row;
when a specific row for a section is selected (didSelectRowAtIndex), you change the data source associated to that section by adding more elements and reloadData on the table.
when a specific row for a section is selected you also modify the data source corresponding to any other section so that it only contains one row.
EDIT:
From your last comment, it seems to me that what you are trying to do is a generic dropdown menu: you click somewhere and it displays; now, in your specific case you are thinking of clicking on a table, but it could in principle be anywhere else. I am saying this (if I am not wrong), because if it is so, then you can find ready-made implementations, like WEPopover, and you could save some effort.
Going back to your asking, in the case you are mentioning, you can animate the height of the table view frame (or bounds), so that its content is displayed little by little, as the view height increases; have a look at this Tutorial about Core Animations.

insert rows in uitableview and update view immediately

I would like to implement a search facility in my iPhone application. The functionality is similar to iBooks search where the results are updated row by row and become visible. Also one row is used to view the search progress.
Any help is appreciated.
Take a look at UISearchDisplayController. It is used together with a UITableView to provide search. You can probably get started by looking here or just google with your favorite search engine for UISearchDisplayController.
You have to use a background thread to update the table periodically.

Creating an alternative way to scroll TableView on iPhone

I currently have a TableView with over 35,000 cells. Obviously the standard iPhone flick-and-scroll becomes inefficient with this many cells. I have already implemented search but still think that a way to scroll the entire table is necessary. I am currently using the
-sectionIndexTitlesForTableView:
method to populate the side with the relevant characters, and I want similar functionality to that in Apple's Remote app. I do not have section titles in my table and simply want the sectionIndex to be an alternative way to scroll through the entire 35,000 cell table. How should I go about doing this?
My instinct tells me that a list that large could probably be broken down into smaller sections that could be filtered using the standard hierarchical navigation on the iPhone - that said, without knowing what exactly the data is I can't say that with any confidence.
You say you don't have any section titles - is the list alphanumeric? If so, what is wrong with having a standard alphabetical sectionIndex and sectionTitles?

How do I create a dictionary-style scroll bar for iPhone (like in the Contacts list)?

I am creating an iPhone app which I would like to have a similar interface to the iPhone's native contact picker view, i.e. an alphabetical list which you can scroll through, with a search bar up top which narrows down the list. Particularly, I'd like to be able to show the letters of the alphabet down the side so that as you scroll through the list, you see your position in the alphabet in the scrollbar. The problem is that my data basically consists of key-value pairs, not contact data, so I can't easily use the native contact picker.
As far as I can see, I have two options to achieve what I want:
Use the ABPeoplePickerNavigationController class and hack it to use an address book which I fill myself with non-address type data. The problem with this is that, by default, the address book will fill up with the contacts from the iPhone so that each time the app opened, I'd have to flush those contacts and build my own list. (Not to mention other problems associated with using an interface which is bound to a particular data structure)
Use a UISearchBar and UIScrollView. This would be fine, but I'm not sure how to do anything to the scroll bar except change its colour - I can't see how to override its contents.
Any advice on which is the simplest way? What are the pitfalls (particularly of 1)?
To get the letters down the side, you can just provide a -sectionIndexTitlesForTableView: method in your table view datasource. As for searching, there's a bit more work there, and it's very dependent on your data. A UISearchBar is the place to start, however.
For a search bar, have a look at TTSearchBar in the Three20 library.
Everything else can be easily implemented using UITableView.