NSToolBar for switchign views in storyboards - OS X (Objective-C) - objective-c

Have been searching quite a while, maybe someone can direct me to a step by step tutorial on understanding how to use NSToolbar to switch between different view controllers and show them below the toolbar. Possibly resizing the window based on the view height and width.
Not familiar with swift, so any objective-c stuff is much obliged. Thank you.

You can use an NSTabViewController with its tabStyle set to NSTabViewControllerTabStyleToolbar.
You can add an NSTabViewItem to the tab view controller for each view controller; with the image of the tab view item set to the image you want in the toolbar.
This can be setup programmatically or in an interface builder storyboard.

Related

How to add a bar on top of a UISplitViewController?

I would like to have a separate bar above the UISplitViewController on iPad. I will use this bar to show a logo.
I did some googling and reading but cannot find a solution to this other than create my completely own subclass to draw my screen like I want it. I'd like to avoid that if possible...
You should read about ViewController Containment to build your own Container Controller.
Helpful links:
iOS Reference: https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html
objc.io article:
http://www.objc.io/issue-1/containment-view-controller.html
Create your own container view controller. In its view this VC will add a navigation bar (or some other view that you can add your logo to) and the split view controllers view. It should also add the split VC as a child.
This is a custom subclass that you will create, but it is minimal code and requires no drawing code from you.

The right way to make a custom UITabBar inside UITabBarController

I'm trying to create an app with UITabBarController, in order to use Cocoa's own memory and view controllers management for switching between different view controllers.
However I do need to make a very custom UITabBar, which after much Googling I found out is not possible. Several things are not possible with original UITabBar:
changing position and size of the TabBar,
adding custom (non-tab) elements to the toolbar, such as search/dropdown
Is there any "legal" method of completely changing the design/subviews of TabBar but in the same time making use of UITabBarController and still getting app approved by Apple?
Thank you for your help.
About changing the size you can extend UITabBar and overwrite the function sizeThatFits.
I'm sorry for not having an answer for the other points.
- (CGSize)sizeThatFits:(CGSize)size {
CGSize auxSize = size;
auxSize.height = 54; // Put here the new height you want
return auxSize;
}
I will tell you as soon as I will discover it.
Not much can be customized in tabbar but there are some good examples :-
Custom Tabbar by iDevRecipes
Custom TabBar by brianCollins
It might not be exactly what you need but will give you direction.

How do I have a Segmented Control that calls different views for a UINavigationController?

I'm an iOS/ObjC newbie, and I'm trying to find the best way to do this... What I want is to have a segmented control that has three options: 1) Map View, 2) List View, and 3) Street View. The SC will be in the bottom toolbar. In all three views, they'll need to be able to tap over to a Detail View.
I tried using a UINavigationController that has the segmented control in its bottom toolbar, but when I switch views, the bottom toolbar disappears. I've also tried loading a ViewController with just the toolbar and an empty view, then loading the navigation controller into that view, but it overlays the toolbar.
Any help would be appreciated!
For the way you described your problem you may consider using a UITabBarController instead of a UINavigationController. It should fit better your needs.
UITabBarController
Its been ages, The best choice is a UITabbarController, if for some reason this is not possible there are other solutions including creating an instance of a SC in all the views or demoting the views into subviews to be put in a horizontal scrollview but only a UITabbarCOntroller will allow him to use 3 distinct navigationControllers for each of his view

UIPopoverController buttons beneath a table view

I was looking to implement something like the image below, and really have no idea how it's done and was wondering if someone had a quick design idea (no code is necessary or anything). Is it a footer view for the table view? is it some unknown footer view for a popover controller? Is it some way to integrate a toolbar from the UINavigationController 'into' the popover? I guess I could always create a custom view and display it 'like' a popover. Thanks for any help.
UIPopoverController will actually do a lot of that for you. If you set its content view controller to a UINavigationController, the contents of that navigation controller’s current view controller’s navigation item will display embedded in the top of the popover. I believe setting the view controller’s (not the navigation controller’s) toolbarItems will have the same effect at the bottom.
In this case, it looks like they wrote a custom popover controller; it doesn’t have an arrow attached, and the top of it is shaded a little differently from the standard UIPopoverController. But I’m pretty sure you can use the methods I just described to achieve a similar effect without having to roll your own popover.

Can I use a UINavigationController as the detail view of a UISplitViewController?

I'm running into a problem with an iPad app where I would like to have UINavigationControllers in both of the views within a UISplitView. I've looked through other similar questions here, but most link to a tutorial online that doesn't completely solve the problem. Here's a 2-minute walkthrough to re-create the problem I'm having:
Create a New Project in XCode, starting from the Split View-based Application template.
Add the following NSLog statement as the first line within the DetailViewController's willHideViewController method:
NSLog(#"toolbar: %#", toolbar);
If you run the application now, the log will show that the DetailViewController's toolbar is alive and well. Now...
Open MainWindow.xib and expand the SplitViewController.
Drag a Navigation Controller from the library on top of the DetailViewController.
Expand the new Navigation Controller and change the class of the UIViewController within to a DetailViewController.
Ctrl-drag from the SplitViewController to the DetailViewController and assign it as the delegate.
Save MainWindow.xib and run the app again.
At this point, the detail view has a navigation bar and an empty toolbar. If you view the logs, you should find that the toolbar is null. Why is this? Am I missing some sort of connection in Interface Builder? Is the navigation bar the problem for some reason?
Unlike the tutorial at http://www.cimgf.com/2010/05/24/fixing-the-uisplitviewcontroller-template/, I would like to keep both the navigation bar and the toolbar (preferably with the toolbar at the top when in portrait and not visible when in landscape), so that I still have a functional "Back" button when the iPad is in portrait orientation.
Does anyone have any suggestions for fixing this problem? An example project with this sort of set-up would be ideal.
You can certainly use a navigation controller on the detail view of a split view controller. In fact, the iPad Settings app uses this approach. Probably the best way to get this setup is to create a new project in Xcode 4.x and select the "Master-Detail Application" template. It will generate a split view controller with 2 navigation controllers, one for the left view and one for the right view.
To your toolbar question, to keep things simple I would put a toolbar in the bottom. You can still put bar button items on the top navigation bar, although you can only put them in the left, middle, or right. If you need lots of items on the top bar, one way is to add a toolbar to the detail view and hide the navigation bar in the viewWillAppear event of the detail view class.
Here is an example on how to hide the navigation bar and show the toolbar:
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.toolbarHidden = NO;
self.navigationController.navigationBarHidden = YES;
}
I've found the built-in UISplitViewController to behave badly when trying to combine it with most of the other built-in view controller subclasses. Matt Gemmell's MGSplitViewController is a lot more flexible and has worked pretty well for me, despite the odd glitches (though those are at least fixable as the source code is provided).