The current setup I have is a UIView over a map view that's meant to encapsulate the search bar (to make it look rounded). However, the first time I click on the search bar, it animates over the view for some reason, and then goes back to normal, but every other time, the animation stays within the view. The images below visualize the problem. I'm not entirely sure how to get started on fixing this -- any tips?
I instantiate the search bar and search results controller programmatically.
normal view (search bar not clicked)
the first time you click on the search bar vs every other time you click on it
I think you need to add constraints to fix this issue. And if possible try adding your search bar inside a UIStackView and then add constraints to the stack view.
Related
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.
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.
I have a table view in first view and it has search bar. From that, I select 1 cell and it will push another view. After that, I come back to my first view and my search bar frame become zero like this. As a result, I can't see search bar but I can still tap on that. In visual debugging, I can still see search bar but on device, it disappear. May I know how it happen like this?
Have you used Tinder app?
That app is full of nice effects that makes a great UX experience in my opinion.
Try to open it and you see the launch image with a red flame at the center of the screen.
Seconds after the flame moves itself to the navigation bar to make the app logo.
The animation I am trying to create it exactly that and I can't figured out how to (1) let the navigation bar appear in that way and (2) to transition a custom UIView inside another view.
If I'd find an app to record the screen of my iPhone I will post a video explaining the animation I'm referring to.
In the meanwhile, do you have any ideas?
The animation I am trying to create it exactly that and I can't
figured out how to (1) let the navigation bar appear in that way and
(2) to transition a custom UIView inside another view.
Animation's are often not exactly what they seem to be. For example, when you segue from one view controller to another the animation you see often uses images instead of transforming the actual views.
You can do the same kind of thing for the animation you want. You don't have to actually move a view from one view controller to another -- just create the appearance that you did:
Create an animation that moves the image in question (like the flame) into position on top of the navigation bar.
Set the titleView of the destination view controller's navigation item to include the same image in the same location.
Remove the animated image. The user won't notice a change because the same image is already present at that location.
Hei guys.
What I am trying to achieve is have my search bar behind the navigation controller just like in the sparrow app. So when you scroll down the search bar is basically part of the view.
The first picture is the view when it's first loaded. The second one is after I scrolled down.
Do you know any way I can achieve this? I was thinking of having the search bar as part of the view and just load the view form the point that's just under the search bar. But I don't know how to do that. Any help would be much appreciated. Thanks.
I agree with #holex's comment if you're using a tableview. Seems silly to re-implement.
However, in the unlikely event you're not. You could just use a UIScrollView for your content and place the search bar at the top, and adjust the content offset accordingly. So it would appear as if the search bar has animated from under your navigation bar.
Here's a link to the UIScrolView class page on the dev site