UISearchDisplayController search bar position - ios

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?

Related

why status bar behaves differently - swift

I'm using a tabbar controller and in each tab, I have a uiview controller embedded in a navigation controller. in each view of mt view controllers, I have a scroll view. everything is the same but when I run it, I get different appears for status bar. why is this happening?
first tab:
second tab:
notice the white background color in second tab that does not exist in first tab. What causes sth like this?

iOS Swift: Incorrect Navigation Bar Appearing

The incorrect navigation bar is appearing on my Table View Controller screen (see Storyboard Below).
I would like what's displayed on the storyboard to be my navigation bar (i.e. with "Main Feed" title and Sign Out button on the top right). However, this is what I'm actually getting -
There are two issues here: 1) The incorrect navigation bar is displaying (this one has a login back button); 2) the first few table view cells are placed underneath the nav bar vs. under it.
This happened after I embedded the Table View controller in the Tab Bar Controller. I want a bottom tab bar in the main portion of my application hence the reason why I added the Tab Bar Controller. Any suggestions on how to fix this? Rather than using the Tab Bar Controller in storyboard, is there a way to do this programatically? Thanks!
The navigation bar that you are seeing on top of the stack is the navigation bar from the UITabBarController itself, that is why you are seeing the back button show "login". There's a few ways to work around this, programmatically:
When you initialize the UITabBarController, set it's navigationController's navigation bar property to "hidden"
Go through each view controller form the beginning of your app up to where you first see this problem and in the "init" method of the viewController you are testing, set the navigationbar to hidden. Something like, self.navigationController?.navigationBar.hidden = true;
This is how you can "debug" this issue, but it's going to take some tweaking to get it right.

How to Add a Bar Button Item on a Disappeared Navigation Bar using Storyboard?

I want to add a bar button item on the navigation bar. (Say View 1 here.) The view that will segue to View 1 is embedded in a navigation controller.
However, the navigation bar is not showing in this view.
If I use attribute inspector to add a opaque/ translucent navigation bar, there will be a navigation bar in View 1. But if I drag in a bar button item, it cannot be shown in the storyboard. Though the bar button is in the document outline, it cannot be shown on the storyboard. Also, if I run the application, it is not on the screen.
When running the application in the simulator, View 1 will have a navigation bar on the top of it, since I use "Show" rather than "Show Details" to show View 1. I tried to embed View 1 in a navigation controller again, but it won't help much.
Can anyone tell me how to add a bar button in this situation using storyboard? And why the navigation bar is missing from the storyboard?
Thanks in advance.
I figure it out by myself.
Drag a Navigation Item from the object list, and then add bar button item to it.
Thanks to rdelmar for his idea, though drag out a navigation bar won't work in the way I thought it should work.
In my situation, View 1 is a table view. Drag a navigation bar to the view will cause it to be the header view for the table, rather than a navigation bar I had expected. Then there will be two navigation bar in the view when I run the application.
Of course we can drag out a navigation bar and add a button to it, it might work different with your expectation. As I had said, it might leads to a view which contains two navigation bars.
You can fix this by drag out the Navigation Item (contains the bar button you had added) inside the Navigation Bar out. In my situation, I drag it out and put it the same level with the table view inside the document outline. Then it won't become the header view for the table view.
After that, we can just delete the navigation bar from the document outline.
I have no idea why the navigation bar disappears in my storyboard. If anyone has some idea for this, please let me know.
It sounds like you're adding the navigation bar by using the Simulated Metrics. If so, this doesn't add one at run time, it's only for layout purposes in IB. You should drag out a navigation bar from the objects list, and add your button to it.

uipageviewcontroller with search bar not showing up

I have an ios7 app that is using a page view controller to swipe through a series of pages. I want to have a navigation bar and a tool bar above this. Heres a picture of what I mean:
http://i.stack.imgur.com/ddgXY.png
I have 3 views going to build this.
Root - a view controller embedded in a navigation grontroller
Page View Controller - a page view controller
Page - a view controller that represents the page (aka the big white box)
The root and page views are both subclassed from UIViewController
The search bar is in the root with the rest of the top navigation. The navigation bar is fine (the menu button works) but I can't get the search bar to work. It seems like the search bar is covered by either the page view controller or the page. This is because it is only visible when I make the page background transparent (and if I bump up the space between pages, you can see it peaking thru between them as you swipe). Even if I make the page background transparent, the taps don't make it thru and the keyboard never comes up.
I need a way to get this search bar to be visable and usable. I don't want to put it in the page view because then it looks bad as you swipe thru the pages, like each page has one. I want it sticky like the red navigation bar.
also, I'm using storyboards.
You could always put the search bar in the navigation bar instead of the title. Just drag the search bar to the title of the navigation bar

Tab Bar Controller - Show a view controller that is not one of the tabs

I wonder if this is possible. The design for this app I am working on is as below:
Two sliding views sit one on top of the other. The bottom view is a 'Settings' view. The top view is a tab bar view. We are using ECSlidingViewController for the sliding.
When the app is opened for the first time, the tab bar view shows with first tab selected.
When they tap on the hamburger menu or slide right, the bottom, settings view slides into view.
When they tap on an item in the settings view, like the About item, the corresponding view should be displayed inside the top tab bar view with none of the tabs shown as selected.
I think I am going to have to convince my team to not display the settings items inside of the tab bar, it seems just too twisted. But just wanted to know if anyone else has done anything like this and if it is possible to do it without introducing too much complication in the code.
I've done something with the same design with a menu that slides from the left and over the tab bars. I ended up putting a View Controller on top of everything else
Something like
[self presentViewController:AboutViewController Animated:YES];
Just make sure that you either put that view controller in a UINavigationController or something with a dismissViewController for users to return to your main page.

Resources