Buttons and input field into "top" bar - xcode

Safari on iPad has this bar at the top (it isn't called "toolbar" on iOS, right?), with some icons and input are for searching.
How to put such buttons and input field into Navigation Bar? Is it even a Navigation Bar? From what I read a Navigation Bar has one button on the left, another one on the right and one Label in the middle. But how to create something like that "top" bar from Safari?
If I'm in XCode 4.0 and choose "View-based app", should I then set in the ViewController > Simulated Metrics > Top Bar > Navigation bar? And how to add buttons to it?
Edit
Sorry for the confusion - I don't know if the proper way is to add to a Navigation Bar. I'm just asking for a general overview how such "top "bar" is made. What kind of View do such items belong under?

You probably don't want to use a navigation bar. They are very limited in what controls you can put in them. Try using a UIToolbar instead.

I think you may be looking for the UISearchBar
UISearchBar Sample Code

In the interface builder you should be able to just drag and drop objects onto the navigation bar, as for the little icons, those are just buttons with no border and images. Those images are preloaded in the iOS SDK, so you won't have to make them, but if you want your own then you can make them yourself.

Related

Xcode 6.4 - Navigation Bar not editable

Just to prove I'm not going mad here's my app working, complete with a Nav Bar.
But this is what it looks like in the Main.storyboard, no Nav Bar.
I have rectified this is the past by disconnecting the link from the TabBar controller and restablishing it. I want to be able to edit Nav Bar as I seem to have two back buttons. One comes up and < and the other as < Back, shown top.
What's the fix and have I created the View in the wrong order?
Many thanks.
Here's an image of where to go if you need a navigation bar in a View Controller.
If you need to add Bar Buttons, you can use a Navigation Item as well.

Use combined titlebar + toolbar while preserving title visibility

The System Preferences app feature a combined title bar and toolbar with vertically centered buttons and the title. I am trying to mimic this exactly in my app. I have been able to combine the title bar and toolbar using Interface Builder (on the NSWindow check Title Bar and Unified Title and Toolbar), but this does not center the content vertically. I discovered via this question you can simply set the window's titleVisibility to NSWindowTitleHidden which will vertically center the stoplight buttons. Unfortunately this of course hides the title. How can one vertically center content in the unified titlebar/toolbar and also show the window's title just like System Preferences - either in IB or programmatically?
I ended up setting titleVisibility to NSWindowTitleHidden and manually created an NSView that contains an NSTextField that mimics the standard title appearance, providing that to the window's addTitlebarAccessoryViewController method. Still would like to find a better solution to use the default title appearance, if possible.
I used WAYAppStoreWindow on GitHub to do this. I created a fork of the WAYWindow subproject to vertically centre the document title since this wasn't supported. This means any applied themes/appearances are honoured.

How can I get a two-row toolbar like in Mail.app and Xcode?

I'm trying to add a "second row" after my NSToolbar in my app, that remains part of the title bar. As an example, Mail has a thin gray divider line below the NSToolbar with some extras items below that. Very specifically, when the window is put into fullscreen mode, that second "row" stays attached to the title bar as it slides down under the system menu bar. Xcode has a similar story.
I tried setting my NSWindow to textured and placing my second row controls directly in the content view of the window. While this mostly looks correct in windowed mode, those controls of course won't appear attached to the toolbar when it slides down in fullscreen mode. So how can I achieve the same behavior that Mail and Xcode do? I've looked at a lot of toolbar customization code but none of them really cover this specific case.
fullScreenAccessoryView is deprecated in macOS 10.10
In order to do this in recent versions of macOS, use the addTitlebarAccessoryViewController method on your NSWindow and pass in a subclass of NSTitlebarAccessoryViewController.
For example:
NSTitlebarAccessoryViewController *accessoryViewController = [[NSStoryboard storyboardWithName:#"Main" bundle:nil] instantiateControllerWithIdentifier:#"AccessoryViewController"];
[self.mainWindowController.window addTitlebarAccessoryViewController:accessoryViewController];
What I needed to do was call [NSToolbar setFullScreenAccessoryView:] on the view below my toolbar. This results in the behavior I was aiming for. See the NSToolbar documentation for this method.
First one is normal toolbar. For second toolbar you can create a separate view of your desired height and add it in the main landing-window.

Incorporating navigation bar in UIViewController in Interface Builder

I'm using Xcode 4, but not Storyboards
We have a navigation controller instantiated in the app delegate.
When we create view controllers with Xibs the xibs are views that are the height of the iphone (without the navigation bar). Putting content in this area is deceptive as there is actually 44pt's less space (the height of the nav bar) which gets put there by the navigation controller.
Therefore how do we remove the room where the nav bar should be in interface builder?
I can click the view and then change the "top bar" to "navigation bar" which will work, but I cannot add bar button items to this navigation bar, which makes me think that this is not the correct way to do it.
Can anyone let me know what the best way to do this is?
Many thanks
When you push your controller or use it to init the navigation controller, the navigation controller should take care of resizing at run time. The area in IB where you set the top bar is under the heading "Simulated Metrics" and is meant to give you a preview of what your selected interface elements will do to your available display area. The "Simulated" part is why you can't put items into that bar.
The real navigation bar should be configured wherever the navigation controller is defined, whether in code or a xib.

How do I build a toolbar in my title bar?

I have to implement a custom toolbar for my application, where a button will be placed on the side of exit, maximize and minimize buttons.
I tried to work with the toolbar element on XCode, but it always put elements below these buttons and not on the side.
App Store application implement this feature, like you can see in this image.
One solution is to start with this open source code (https://github.com/indragiek/INAppStoreWindow) to give you the correct title bar style, and then position buttons in the titlebar.

Resources