I am working on a app for the iPad which has a tableView on the left and a view on the right. We are not using the UISplitViewController.
I have been able to setup filtered results using the Search Display Controller and a search bar, but the search results take up the entire screen.
Ideally, I would like to have the search results only take up the same amount of screen as our tableView. Or, barring that, have a way to dismiss the search results when 'didSelectRowAtIndexPath' is activated.
I'm not sure what code I should post. I'm using the code from the Apple code sample: TableSearch.
on the comment below: something like this..?
[self.searchDisplayController.searchResultsTableView setFrame:myTableView.view];
By default, table views take up the whole screen, but there is nothing stopping you from setting their frame.
Just call -setFrame on the searchResultsTableView property of your search display controller.
Related
I've currently got a single working UISearchController implemented inside the header view of a UITableViewController. I wish for my other views to also follow suit but some are UICollectionViewControllers. Is there a way to create one UISearchController and just call them across all the views within the headers? All of the results must show in a table.
I had attempted to create one for each view but the UICollectionViewController was giving me some problems. I couldn't figure out how to set and update a table for the search controller. It wouldn't allow me to override the tableView methods as i guess the controller is a CollectionView.
Any help is appreciated.
EDIT:
Should also add that the search method/data will be the same across all of the views. See how the stock iOS Music app uses search bars as an example.
EDIT 2:
I've nearly cracked it (I think). I've setup a singleton "SharingManager", within this i have 3 arrays. Now I have 2 views, one named ArtistsView and one SearchTableViewController. The Search view contains all of the table methods and the ArtistsView communicates with that using:
self.searchResultsController = UISearchController(searchResultsController: SearchTableViewController())
I also copy the variables within the singleton to variables that are within the SearchTableViewController.
The issue i'm having now is that the cellForRowAtIndexItem method is not being called. All the other ones are, i can even see the section headings are being displayed. I have set up various println() statements to see where i could've gone wrong, the numberOfRowsInSection is also returning the correct numbers. Any ideas?
What I have done in the past to solve this kind of issue, and what seems to be the most flexible is to have it so that when you tap on the searchbar, your app actually transitions to another view controller that handles the search and search results.
Fake search bar button on each screen you wish to use it.
When tapping the search bar, screen cap your current view controller.
Set the screen cap to the background of your search results controller, blurred or darkened a bit if you like, so it doesn't interfere with the search results.
Transition between your previous view controller and the new search results controller with a fade.
You'll be able to give the user the impression that they never left the original screen they were on.
So currently when my searchDisplayController becomes active my section index list positions itself and changes its length in weird ways.
When I first enter a letter into the search bar this is what it looks like.
When I keep on entering characters into the search bar it looks like this.
Then, when I dismiss the key board the section index list moves down with the keyboard and looks like this.
I have set up an NSNotificationCenter UIKeyboardDidHideNotification observer and tried doing searchDisplayController?.searchResultsTableView.reloadData() and
searchDisplayController?.searchResultsTableView.setNeedsDisplay() in the selector function and it does not fix or even change anything.
This issues happens in both portrait and landscape but fixes itself upon device orientation change.
Any ideas in how to fix this or just a simple point in the right direction would be much appreciated :)
EDIT:
So, the first screen shot is what it is supposed to look like and it allows me to scroll the tableView with the keyboard up. When I dismiss the keyBoard it aligns up correctly. However after a put in a second character into the search it changes to screenshot #2 which does not allow me to use the section index list to scroll through the tableView.
I need to display search results for my custom control and I'm not so sure what is the best way to make this configurable.
Basically the control is similar to the UITextField but with more visualization. When the user enters some text to the field, the control would enter full screen so that the search field is on top and the results are displayed beneath. This would be very similar way to address search in Apple's Mail.app (see the attached picture).
The issue here is what would the "full screen" mean on an iPhone. If the view is presented from a table view cell, the parent view's frame is not good. The window's bounds do not work as I want to keep the navigation bar visible if there is one. Also, the full screen would be different with the iPad. With the iPad, I think I could use the pop over.
I was thinking if the controller using my custom control would provide the bounds (a delegate method perhaps?) but that feels somewhat cumbersome.
Any ideas would be appreciated.
Update:
So far I've come to a conclusion that the iPad and iPhone versions of this have to have their own specializations of the results display. On an iPad, the popover is quite trivial to implement. On an iPhone, I really can't figure out the proper way to determine the bounds for the expanded control (the text field and results table).
It is hard to describe the problem, but all I'd really need is means to expand the control to occupy some bounds (in most cases the space between the keyboard and navigation bar).
I need to create an app for ipad.Its something like the contacts app in ipad.(like an open book)
My doubts are whether they are using split view or two different views.
If splitview is used,how could we increase its width and style?
You can tell that they are not using a split view controller by turning the screen vertically: split view moves the master into a popover; contacts simply rotates, without popping the master portion out. I think that they use a single, highly customized, view for the contacts.
The background can be just a chunk of graphic or a picture. On top of that you'd add your own or Apples UI elements.
Each functional area should probably be implemented as a separate subview, ie. the UITableView on the left, the index on the right and so forth.
In your words - implement it as separate views not a split view.
If you want something like that (don't know why you would... the Contacts app is horrible) then you're going to look past the default set of UI elements provided to you by Apple.
UIViewController, UITableView are really the only two things you'd be reusing for something like that.
My iPad app uses a popover to perform some searching. The search results are handled using a UISearchDisplayController, and I am having some trouble removing some little graphical artefacts.
My popover starts out looking like this:
When you click inside the search bar, the popover expands (animated) to:
All good so far... typing in the search field overlays a new table view showing the results of your search term.
But if you don't type anything into the search field, the overlay stays translucent, as above. The problem then comes when you click the cancel button next to the search field. A visual artefact appears at the bottom of the table view: an area the same height as one of the table view cells goes completely clear immediately, while the rest of the overlay animates to 0 alpha. The screenshot below is as close to the start of the animation I could get:
The popover also resizes to the original size in my case, although the artefact remains even if there is no resizing.
Given that all the important functionality of the search is handled by the UISearchDisplayController, I'm not sure what to change to solve this problem. Any ideas?
This might be a bug worth reporting. There are actually a surprising number of bugs in UIPopoverController. At least 3 that I know about separate from this, none of which are planned to be fixed anytime soon (I asked several engineers at WWDC this year). One of my bugs was actually related to the UISearchDisplayController in a popover, specifically how it handles filter buttons if the Popover is in the detail view (it renders them in the worst possible way, on the same line as the text view and completely unusable).