I have a problem with my UISearchDisplayController.
My view is build with a tableview and a uisearchdisplaycontroller on it.
When the user tap on the search bar (that is displayed inside the navigation bar) it opens and shows the suggestions (that are fetched via json).
When the user performs the search, tapping on "search" via the keyboard I need that when he taps on a result (that is on the table but with different cell style and identifier) the tap is recognized by the searchdisplaycontroller but not by my app code.
Notice that didSelectRowAtIndexPath: is not called when tapping, but instead my app shows again the search bar in editing mode.
How can I disable this behaviour?
Related
It seems that the default behavior of the UISearchController is to display an empty table as soon as characters are entered in the UISearchBar. The search I'm implementing doesn't search as the characters are entered, but it searches when the Search button is tapped.
Because of this, I don't want to display an empty table until the actual search happens. How do I make this happen?
I've tried to set the table hidden until the search button is tapped, but it doesn't seem like the empty table that appears is the same as the UISearchController table, because none of the datasource methods are called on that table.
The empty table view you are seeing is from your search results controller, which is "immediately" displayed by UISearchController "when the user enters text in the search bar". (source)
Hiding the table view in your search results controller until you are ready to show it would seem to be the easiest solution. But as you discovered, upon displaying the search results controller, UISearchController sets the value of the isHidden property on the root view to false. In my debugging session, UISearchController behaved this way every time the search bar began editing or the search text changed, by calling a private method named _updateVisibilityOfSearchResultsForSearchBar:.
You can work around that behaviour by adding the table view in the search results controller as a subview of the root view (and then hiding or showing the table view as necessary), or by adjusting the value of the alpha property for the root view (which, unlike isHidden, can be animated).
In this case, you can do work around like creating a UIView and adding as subview over the tableview to make it hidden. Once user clicks on search button remove that view.
I am designing an iOS app with swift which looks like in the picture.
When the user taps on the search bar (first image), a new view should appear (second image) while the search bar stays focused. When the user puts in some search query the expanded view shall be updated. When the user selects a result, the expanded view should go away and show the table view with updated results (third image).
How can I model this custom search bar behavior?
I think the best way to achieve this scheme is to create 2 view..let's say for example A and B.
In view A there is a searchBar and your tableview with different cell. When searchBar got focused or is clicked view B is presented. When a cell is selected, view A is presented back calling maybe API for new data
I have a UITableView in which i have added UISearchDisplayController on the header of the table view in xib.
When i run the project and click on search bar textfield which show cancel button. When i click on cancel button multiple times frequently then UISearchBar is disappear from the header of the table view.
You can download the sample app from below url.
https://www.dropbox.com/s/3ero6u76dceq4r7/SearchBarSample.zip?dl=0
Any help is much appreciated. Thanks!
You have taken the search bar inside tableview. Just take it out of the tableview. Search bar should be above in list. The problem will be resolved.enter image description here
We use the standard UISearchDisplayController in a project built on iOS 6.1 SDK. There appears to be a bug when running the application on an iOS7 device - The controller lying underneath the modal controller gets the user interaction instead of the UISearchDisplayController.
Steps to reproduce:
Click on the search bar to give the UISearchDisplayController focus (modal view is shown on top of the viewcontroller lying underneath and the search bar is moved to the top of the window)
Write something in the search field to get the table view with results to show up
Click on the clear search field icon (X) or backspace the text in the search field
Now the modal view is shown instead of the table view
At this point if the user clicks on the modal view, the click is caught by the viewcontroller lying underneath the modal view causing faulty behaviour. This problem still remains even if the table view is shown again after the user has done another search.
Has someone else noticed this bug, and has anyone a solution to this problem?
I have a horizontally scrolling UITableView on the bottom of my iPad app, and when the user taps on one of the cells, I pop up a UIActionSheet from it allowing them to select between two options.
That part works fine, but I'm running into two UI problems when dismissing the actionsheet.
1) When the user clicks outside of the UIActionSheet and not a different UITableViewCell, I'd like to deselect that cell immediately and then dismiss the UIActionSheet, or fade them both out at the same time. However, when I implement
(void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex
to do this, it still results in the actionsheet slowly fading out before deselecting the cell, which just looks a little odd. It happens whether I'm calling [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:NO], by getting that cell and changing the appearance manually, or reloading the table. Even if I maintain a reference to the UIActionSheet from when I create it (e.g. self.actionSheet) and set it to hidden or nil when willDismissWithButtonIndex is called, it still operates this way.
2) If the user clicks outside the UIActionSheet but selects another TableViewCell, I'd like to instantly shift the UIActionSheet to the other cell. Right now, however, it just fades out slowly and then the user has to tap the new cell again in order to bring up the UIActionSheet for that cell.
Anyone have suggestions or experience with this issue?
All the best,
Toby
From the UIActionSheet class reference:
For applications running on iPad devices, the action sheet is typically displayed in a popover that is anchored to the starting view in an appropriate way. Taps outside of the popover automatically dismiss the action sheet, as do taps within any custom buttons. You can also dismiss it programmatically.
So I do not think you can change the behaviour of this UIActionSheet when user taps outside to select another cell in your app. You might want to just create your custom pop over view to address your two issues.