Swift iOS search bar loads custom view - ios

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

Related

UISearchController iOS 11 not in navigation bar busted?

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:

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.

Add an inputview to UIButton for on click event iOS

I am building a page for a Swift iOS app and I want the user to be able to specify the date range for a graph. At the top of my graph I want the user to select a date range by clicking on a button which will gray out the screen and bring up a picker view on the bottom of the screen to select the date range. It's very similar to how the myfitnesspal app does it (below):
As you can see when they click on the calendar button it brings up a pickerview while graying out the rest of the screen and only recognizes touches to the pickerview. I basically want to replicate this kind of method that allows me to bring up a custom picker when a button is clicked.
I have tried using UIActionSheet however that is now deprecated and I've read that an action sheet should not be used for this kind of functionality.
You can do this by designing a view controller such that-
It has a background view that covers entire screen with background color as black with some alpha say 0.3. This view will serve to block out any touches on the views behind it. Basically it will have that translucent background effect.
Have your actual view such as picker view as a sibling of this, add other siblings like the cross button, etc. You can use the cross button to initiate closing of the view.
Present this controller as a child view controller on the controller where you need this.

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?

UINavigationBar with Search icon - push modal search view when clicked

I am creating a Navigation-Based application. The nav bar has a search icon; when it is clicked I push a SearchViewController onto the navigation controller (containing a search bar and tableview).
I am hiding the table view when the search view loads in an attempt to have the previous view (the view from which the search icon was selected) show behind the search view, but it appears that the navigation controller is removing this view. If I add the search view as a subview on the appDelegates's window I can see the previous view behind the search view, but the app crashes when I click in the search bar (it doesn't appear to give control to the view controller attached to the search view).
I am looking for any suggestions on how to achieve my desired result?
Thanks.
it sure is late as a response... but uinavigationbar's push view...
pushes a new view controller, removing the old one from the active window...
if you want to have a search controller behave like that, you should use a UISearchBarController and set it's search bar as header of your original table view..
the searchbar controller will show and hide the search result table view, if you want the old table to be shown, you should change the table on the search bar, so it's transparent first.
Pushing a new view is not a solution because you totally change the old view (remove it from the window)
greetings

Resources