Custom navigation controller to show fix top menu - ios

I want to create a fixed top menu with buttons to navigate through views, right now i have a navigation controller but I don't know how I can present a view controller from the navigation controller and I don't want the back functionality that included in the navigation controller. Is there an easier way were I can use a view controller as a menu and have it always presented static on top, even if the views underneath is changed?
What kind of controller would be easiest controller to use, to create a fixed top menu?

This is the basic setup.
The top bar is a UIToolbar with four barbutonItems
You could imbed the child view controller in the container view and switch the child view controllers when user tap the buttons.

It sounds like you want to create your own parent view controller. I suggest you create a custom UIViewController that has a container view on it, and that you load child view controllers into the container view based on the user's interaction with your navigation menu. This is pretty straightforward to do.
Your view controller will probably act more like a tab bar controller than a navigation controller if I understand what you're looking for.

Related

How to reposition the UINavigationBar in iOS?

How to reposition the UINavigationBar in iOS? I need to have a sticky UI component on top of it so that it is persistent while the user going from the home page to the subpages?
When you use a UINavigationViewController, the navigation created internally, and is positioned at the top. There isn't much you can do about it from within the view controller's in it's navigation stack.
However, navigation view controller, is just a view controller, and you can add it's view in another view, or embed it within a container view :
Now, you can have any custom content above (or around) your navigation controller
Further reading:
Creating a Custom Container View Controller
Implementing a Container View Controller

What is actually inside navigationController's "view" property?

I was going through Apple's documentation about navigation controller and find this point ambiguous and hard to comprehend.
It was written in this online documentation of navigation controller.
Navigation Controller Views
A navigation controller is a container view controller—that is, it
embeds the content of other view controllers inside of itself. You
access a navigation controller’s view from its view property. This
view incorporates the navigation bar, an optional toolbar, and the
content view corresponding to the topmost view controller. Figure 2
shows how these views are assembled to present the overall navigation
interface. (In this figure, the navigation interface is further
embedded inside a tab bar interface.) Although the content of the
navigation bar and toolbar views changes, the views themselves do not.
The only view that actually changes is the custom content view
provided by the topmost view controller on the navigation stack.
From that, my understanding is that inside this "view" property. There should be at least two subview inside this view.One is the navigationBar the other is the contentView of the current displayed viewController’s view. But while I am debugging only the navigation bar showed with another view called UINavigationTransitionView showed.
My question is, is this normal. Have I done anything wrong?
Second, what is the most common way to access current displayed viewController's view with only the reference to the navigation controller.
Thanks
UINavigationTransitionView controller contains one wrapper view which intern will have the current uiviewcontroller's view.
You can probably find this view as a subview of UINavigationTransitionView. However this is not the "right" way to do this. The proper way is to go through property "topViewController" and then take its view:
self.navigationController.topViewController.view
If there is another view controller or its view that you need, you have access to whole view controller's hierarchy across navigation controller through viewControllers property.
self.navigationController.viewControllers
More here:
https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UINavigationController_Class/index.html

Add StatusBar Like View in App?

In my app I want to add a view much like the status bar, always onscreen at the top of each of my view controllers, displaying application wide data.
I really have no clue how I might achieve this so any suggestions would be really helpful. I;m sure someone must have chased this idea at some point?
Thanks.
What you're willing to do is fairly straightforward since iOS 5 using view controller containment, it allows you to embed child view controllers in a parent view controller.
In your case I would create a custom container view controller with two subviews: the content view and the statusbar-like view. The content view should display your current root view controller by adding it as a child view controller to your container view controller and adding its view as a subview to the content view. The statusbar-like view can then be used to display information that will be visible everywhere in your app.
You might want to read this documentation for further details:
Creating Custom Container View Controllers
You can create your custom view and add it as a subview to your keyWindow. This way it will always be visible. Another option is if you have tab bar controller or a navigation controller as your root view controller, then you can add that view as a subview to their respective view and it will always be visible.

Modally Presenting a Navigation View Controller in a UITabBarController With a Segmented Control

I've spent the past few days searching on the web for a solution to my problem, however, I can't seem to find a problem similar to mine. I am using a TabBarController and on one of the tabs I have a segmented Control in the navigation bar that I would like to use to switch between view controllers. The problem is that when I present the second view Controller it appears over the tabbarcontroller. Is there anyway to keep the modally presented Navigation controller in the tabbarcontroller?
This is the first controller.
And this is the controller I am trying to present.
well we can't really comment unless we saw some code. But I think your problem may be to do with your view hierarchy. If I was going to build what you are attempting I would do as follows:
UITabbar controller that contains a custom navigation bar controller
The custom nav bar controller would contain the segment controller and have a protocol defined so that a delegate could be alerted when either segment was selected by the user.
The nav bar's root view controller would be a view controller that acted as a UIView container for the two screens you are displaying (friends and circle screens)
This root view controller would be the delegate for the custom nav controller so that it will know when the user selected a segment.
When the user selected a segment the root view controller would then switch between the friends and circles view controllers in the container.
To do the above have a look at the documentation for creating UIViewController Containers and working with delegates
Hope that helps!

SplitViewController_Problem

Can we implement split view controller in a normal view controller as in my application we are implementing a tab bar controller and we need to put this split view in some other view and not in window because i just need to know if we are not making a split view based application can we put split view controller in any separate view but not in appdelegate(Window) If Yes please give me possibe solution...
Yes, this would work if you added it to a tab bar controller. Just create all the files for the split view just like XCode sets up a split view project and add the split view controller as a TabBar item just as you would any other view controller. I wouldn't recommend adding the the split view controller in any subview of a view controller in your tab bar as it will not to receive many useful lifecycle events.

Resources