UISearchController iOS 11 not in navigation bar busted? - ios

I have an app in production. On iPad, the layout is 2 table views on one layout. There is a search bar for the left hand table view. In iOS 9/10 this worked fine- the search bar, when expanded, simply appeared in the table view. In iOS 11, the same code will make the search bar expand out of the table view and attach to the nav bar area at the top of the screen.
If I change the presentation context of the search controller, then in iOS 11 it is completely broken and does not work.
self.definesPresentationContext = YES; //YES PRESENTS SEARCH BAR IN TABLE VIEW
I have created a demo project to simplify the example, this is directly Apple's table demo with the table view made as not full screen. The presentation context can be set to either the table view or not, and the search bar scope buttons can be easily added or not.
In the demo, the search controller, when presented inside of the table view, can be tapped in order to start a search, but is completely unresponsive to any taps - the cancel button, the X to clear text, trying to move the cursor. Keyboard text entry works and it will correctly filter the items. But then you're stuck and can't exit.
Here's a link to the demo project. Am I missing something or is this an Apple bug? Majority of code in APLMainTableViewController.m.
DOWNLOAD CODE EXAMPLE at this link
Full app image:
Correctly working search in iOS 10:
Demo project screenshot with bad search controller:

Related

Do you have to put the UISearchBar in a UITableView?

I would like to use a UISearchBar and put it towards the bottom of a screen in order to search for available names through an API call. I want to have this SearchBar as part of a sign up form. However, when I put the SearchBar on the screen where I would like through the Storyboard, it does not show up when I run the app on the simulator. When I looked up this issue, everyone is putting the searchbar in a tableview. Am I not using the correct UI element for my cause?
The reason your search bar is not on the screen is probably because you didn't set constraint correctly or it was hidden or covered by some other view.
And for your second half of the question, I myself never put a search bar on a UITableView itself. Some apps put a search bar on the first cell of a table view but you have to scroll to make it show up. I myself always prefer to put it on the navigation controller on the top of the screen so that it will always be there and ready for user to search anything.

Swift iOS search bar loads custom 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

Using RealmSearchViewController with a UITableView

I'm developing my first app in swift, which has a table that shows data stored using Realm. I've managed to add stuff to the Realm and show it in a table. Afterwards I wanted to add search capability and stumbled upon these two guides: http://www.raywenderlich.com/81615/introduction-to-realm and https://realm.io/news/building-an-ios-search-controller-in-swift/. I would like to use RealmSearchViewController, but I can’t seem to fit it to my setup. I tried using a UITableViewController embedded in a Navigation Controller, but I need a button at the bottom of the screen, where the user should tap to add an entry to the list. I tried using a tableFooterView with a button, but it can only stick to the bottom of the table and not the bottom of the screen. I also tried using a Tool Bar and a Tab Bar in the Navigation Controller, but it doesn’t show as the table takes up the whole screen.
What I would like to achieve is something like Airmail for iPhone, where there’s a Tab Bar at the bottom that is hidden when the user scrolls. Above the Tab Bar I’d like a table with content from the Realm, and then a Search Bar, which is directly below the Navigation Bar. I’d like to use RealmSearchViewController as it makes searching a lot easier, but how can I adapt it to be used with a Table View and not a Table View Controller?
Any other suggestions as to how I can achieve the same functionality?
Thanks!
My recommendation would be to create a parent view controller that arranges the the view of RealmSearchViewController so that it doesn't cover the entire screen, and then arrange a UIButton at the bottom.
You can do this in a Xib/Storyboard by arranging a view and a button with autolayout and then simply add the view from RealmSearchViewController as a subview to the view in this parent view controller.

Is UISplitViewController automatically linked to a UITableView?

I'm trying to make an iPad version of the app I am developing. The app works really well on iPhones but I'm facing problems on iPads.
Basically, in the iPad version, I add a UISplitViewController containing a UITabBarController as main controller ( left side of the screen ) whose first view controller contains a UITableViewController.
There is a UISearchBar to allow the user to filter the table view.
The problem is, on the iPad version, when I use the search bar, an other table view - with filtered content - pops up with an "arrow" pointing at the search bar.
My question is : what is this other table view that appears and how can I disable it ?
EDIT
I found this on this website
In a few situations, the framework will automatically create and
display a popover for you. One such situation is what happens when a
search bar (a UISearchBar) tied to a search display controller
(UISearchDisplayController) appears in a toolbar (UIToolbar) on the
iPad.
That's exactly what I'm talking about. How can I disable this popover ?
EDIT 2
Just found this topic : UISearchDisplayController automatically creates a UIPopovercontroller to display content search result ?! How to dismiss it?
Problem is : the provided solution doesn't fit my needs. I'd like to be able to search directly through my table view, I just don't want this popover to appear at all.
EDIT 3
Solutions founds :
I am not using UISearchDisplayController anymore.
Either UISearchController or just a selector triggered whenever changes are made on my UISearchBar's text field.

UISearchDisplayController click-through bug on iOS7

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?

Resources