IOS Search bar that appears below navigation - ios

I am attempting to have a search bar tied to my UISearchController that appears below the navigation bar, similar to this:
Currently the search bar replaces the title as is common in most/all IOS apps I've seen. I've attempted to control the search bar presentation through a few methods:
1) Creating a new view that sits underneath the nav bar, and assigning the SearchController's search bar to it.
//instead of:
//navigationItem.titleView = searchBar
//do this:
searchplaceholder.addSubview(searchBar)
However the search bar shows up 1/2 way down the screen.
2)Second attempt was to move the frame of the search bar to origin:
searchBar.frame = CGRectMake(0, 0, self.view.frame.width, searchBar.frame.height)
view.addSubview(searchBar)
resultSearchController?.active = true
Looks good initially:
But as soon as I start typing, the bar jumps low again:
How can i Hijack the SearchController to present it's bar either in the nav bar without hiding the page title or constrain the search bar to appear right under the nav bar?

The long and short of this is that you can not do what I was attempting to do. You create a searchbar that when clicked transitions to a second screen with a searchbar in the header. This provides the cleanest experience compared to what I have listed above.

Related

How to create a Navigation Navigation Bar that becomes fixed at the top after scrolling in swift

I have been doing some research on how to create a navigation bar that get's fixed to the top after scrolling, quite similar to the music app or weather app from Apple as shown below. No need to post the code if it's long and laborious but a link or some direction would be great.
I think what the music app is actually doing is fading away the table view's section header, and then change the navigation bar's title to the appropriate words. To change the navigation bar's title you can do something like this:
self.navigationItem.title = "Flame On"
And if you want to add a custom view to your navigation bar (maybe some buttons), you can do this:
let myView = UIView()
// Customize myView
self.navigationItem.titleView = myView
Hope that helps.

Search bar getting hidden by navigation bar when becomes active

I am facing a weird scenario, I have used a search bar in my application and tied it up with a table view as is seen in the below image!
But when ever I try to search anything the search bar slides up and gets hidden by navigation bar, I have used search bar a number of times and never seen me thing like this below is its screen shot !
I can't remove the navigation bar since I need it, but I just can't figure out why or how it can be happening,
One point to note is that the search bar and it's controller are working perfectly when tried to search, only thing is it's getting hidden behind the navigation bar,
Any help on this would be appreciated, as I just can't figure out its reason.
Try this:
Set the navigation bar's translucent property to NO:
self.navigationController.navigationBar.translucent = NO;
This line will fix the view from being framed underneath the navigation bar and status bar.
If you have to show and hide the navigation bar, then use this code in viewDidLoad
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone; // iOS 7 specific

UISearchDisplayController search bar position

Something has gone terribly wrong... All I have done, is setup a storyboard in Xcode, added a UINavigationController and set a root UIViewController, all of this is in a tab within tab bar controller.
I have added a UISearchDisplayController to the view in the storyboard, and am trying to position the search bar within the navigation bar using the following code in my view controller:
[self.searchDisplayController setDisplaysSearchBarInNavigationBar:YES];
This all works fine and i get the following:
However, when I tap into the search bar to enter content, it goes bezerk and centers itself in the middle of the view like this:
When I tap out of the search bar, it retains its crazy position in the middle of the screen like so...
What is going on here?

Search Bar in Navigation Bar in iOS 7

I'm relatively new to iOS programming and I have a Table View Controller that has a Navigation bar at the top and i'm trying to get the search bar from "search bar and search display controller" to appear in the navigation bar.
I've googled around and i've found that:
self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
is supposed to solve my problem but i'm not sure exactly where I would put it. Does it go in the table view controller or do I have to make another control? I've tried creating a UISearchDisplayController class but I couldn't find a way to link it to the search bar. Any help?
You can put this in the viewDidLoad of your view controller. If you are using story boards you create a UISearchDisplayController and Search bar and drag it into your table header.
Keep in mind that if you use the navigation bar for your search bar, it will not show the scope bar.

Navigation bar with Search bar iPad Monotouch

I want to have a page like this:
It is the map page of the iPad map. As you can see it has a location search bar on the top.
Is it possible to have a search bar like this image on the top when the screen have navigation bar on his top?
EDIT:
More than implementing this, it is important that using a search bar on a navigation bar was not wrong with apples guide line. please help also about this.
Thanks
It is not agains iphone quide line. my application with this search bar approved.
The below code will add uisearch bar to your navigation bar:
LocationSearchBar = new UISearchBar (new RectangleF (0,0,250,44));
UIBarButtonItem searchButtonItem = new UIBarButtonItem (LocationSearchBar );
this .NavigationItem .RightBarButtonItem =searchButtonItem;

Resources