How do I add a search bar below the nav bar in a UISplitViewController? - ipad

How do I add a static search bar (one that doesn't scroll with the UITableView) below the UINavigationController in the root view of a UISplitViewController. The iPad mail app has an example of one of these. Actually I would Ike to add a toolbar with a segmented control instead of a search bar, but I imagine the process is the same.

Yes I meant the left pane of a UISplitViewController, so I guess my question is really
how should I add a static toolbar below the navigation bar when using UITableViewController?
You can add any view (except the new iPad split view) to a navigation controller, not only a UITableView. And the added view may have subviews...
Add a plain UIView to the NavigationController.
In this UIView, add your searchbar first and then your navigation controller below the search bar. You can even add a toolbar at the bottom.
NavigationController
UIView
searchbar
tableview
toolbar

Umm... can you re-word this? Do you mean in the left pane of the UISplitViewController? There is no UINavigationController allowed as the parent of a UISplitViewController -- it gives a runtime error in SDK 3.2.
If what you are saying is essentially "How do I add a search bar in the left pane of a UISplitViewController? Then the answer is the same way you would for any view you display as the left pane. Since both panes take simple UIViewControllers (not just a UITableView), you build a nib in IB with the view, the search bar, below that you then put a UITableView. This is the NIB you assign in the so called "Master interface" (left side).
Most people that have this kind of question think that you can only use a UITableView in the "Master Interface" (since that is what it looks like is happening).

Related

Tabbed application and navigation bar (with title and icons)

In a tabbed application, is it possible to have a navigation bar WITHOUT having to use an entire UINavigationController as a UIViewController? I simply need a navigation bar to position an icon on the right (it should simply open a modal). Of course, I could "fake" it with a UIView, but it's not very elegant.
This is possible with a UINavigationBar placed on the top of a view controller.
It is possible to create one from the storyboard, too. Look for the "Navigation Bar" element in the IB Inspector.
This will behave just like a navigation controler's nav bar, with the exception of the navigation functions.

Swift: Add segmented controller to a navigation bar, and keep the title + nav buttons

I'd like to add a segmented controller to a navigation bar, below the title.
At the moment, I've got a storyboard UITableViewController with a CoreData-sourced dynamic table, embedded in a UINavigationController. I'd like the UISegmentedController to differentiate the sorting of the table.
There seems to be obj-C solutions available stackoverflow.com/questions/29480433/ and stackoverflow.com/questions/18813563, but I'm looking for a Swift solution, that resembles the native apps. I've also tried putting the segmented controller into a table cell with little success (can't get the action recognised). I'd prefer not to abandon the table view controller.
Any suggestions?
I replaced the UITableViewController with a UIViewController and UITableView, then added the UISegmentedController to a UIToolBar positioned below the UINavigationBar.
I used removeShadow for the navbar, then clipsToBounds for the toolbar. I also added another View to simulate the bottom shadow on the toolbar (because I couldn't get the toolbar shadow/background position function to work).

UITabBarController Header with Title

I have been trying to hours to implement a simple UITabBarController where each view (or tab) has an active header (or top bar) with the title of the view. Is there a way in Xcode 6.1.x to create a UITabBarController with pages whose title is reflected in the top bar?
As it currently stands, I cannot get the top bar to show. I'd prefer not to drag navigation bars to each view and do this manually. Also UINavigationControllers are not necessary here, as each tabbed view will only need to display a single page.
Thank you.
Changing the values of those simulated metrics fields on a storyboard or nib will not actually have any effect on the UI. It's a design/layout aid.
You will need to embed the view controllers within navigation controllers or drag navigation bars into the views.

How to add buttons to navigation controller visible after segueing?

I have set up a view controller in Storyboard which is embedded in a navigation controller. In this nav controller I have checked Shows Navigation Bar and Shows Toolbar and enabled a navigation bar and toolbar in Top Bar and Bottom Bar respectively in Simulated Metrics. I then "Show e.g. Push" segue from the view controller to another view controller. On both view controllers I've set up Simulated Metrics the same way, so both the navigation bar and toolbar are visible on all three controllers.
The problem is, I can add bar button items to the first view controller to both the navigation bar and the toolbar, but I cannot add a bar button item to the navigation bar on the second view controller. When I drop a button on the navigation bar, it's added to the toolbar instead. And I cannot double click the nav bar to add a title. In the outline I see there is no navigation item on the second view controller, but it is there in the first view controller.
I can probably add buttons to the navigation bar programmatically, but I want to do this visually in Storyboard. My question is, what is wrong with this setup, or is this a bug with Xcode?
For XCode 6, the UINavigationItem for the 2nd view controller onwards is not added automatically on the View Controller Object inside the storyboard. You will have to drag the UINavigationItem onto the Navigation Bar for that view Controller Object before adding UIBarButtonItem on top of it.
I am not sure why it is designed that way. I only discovered about this a few weeks ago.
If you have a ton of view controllers and very little custom auto-layout stuff in place, you can disable size classes, then re-enable it will add all missing nav bars across your storyboard.
Obviously not recommended if you have a ton of custom auto layout stuff linked up.
If you have just a single UIViewController that's missing a nav bar, just drop a UINavigationItem onto it.
If you're using Xcode 7 beta 4/5, try restarting Xcode it solved the issue for me
I just bumped into this issue and it seems to be affected by the segue that shows the view controller.
If "Kind" setting in segue is "Show (e.g. Push)", it's not possible to drag the item to top right corner. However, if you explicitly change "Kind" setting to "Push", this can be done.
Edit: actually I just noticed that "Push" is deprecated. Not sure what Apple is thinking here. However, you can just change it back to "Show" after adding the button and it seems to work :D
For second view controller in hierarchy, you can setup title in attributes, without adding "navigation item"
I think it is a bug. I had the same problem.I fixed this problem by disable the size classes, then enable it.
You can disable and enable the size classes in Interface builder doc.
It's very simple. You just need to use navigaitonItem first as the holder of the buttons and then you can add barButtonItems on top of that.

Adding a toolbar to a navigation controller

I am completely new to ios development and I am only interested in developing for ios5.
I have an app with some scenes, they are mostly tableviews. I also use a navigation controller
I however need to add some status text and buttons that are always visible in all scenes and thought that a toolbar added to the navigation controller should do the trick.
so i thought that i should only have to drag out a toolbar in storyboard to the navigation controller, but it does not stick there. I can add it to the bar underneath with first responder and navigation controller but that does not help me (small icons).
I can also not add it to my table view (but if i drag out a plain view I can add it there)
do I have to make my own custom navigation class that the navigate view uses and then programatically add my toolbar?
Had the same question recently. Check Attributes Inspector in your ViewController's properties in storyboard. There you can define a Bottom Bar.
Well, inside the UINavigationController, you should have something... A UIViewController for instance. You can easily add a UIToolBar by dragging the object inside the UIView of the UIViewController. What might being happening is that as the root view you have the UITableView, in that case I think you can't do that. But to better understand, just take a small print screen of your StoryBoard.
If you zoom up to 100% on the storyboard it should drag.

Resources