NavigationController with sticky view at top - ios

I have a navigation controller with its root view controller, I need to add a fixed/ sticky view at the top of the root view controller, so that only the content below it navigates whenever I use pushViewController or popViewController, is that possible?
Look at the image below, I want the red area to be fixed/sticky a.k.a doesn't navigate or move when I push or pop, only the blue area to navigate
P.S: The containerView won't work here as it acts as normal view, and adds its sub view controller's view to it.

Add a container View to add as child view controller for your navigation and set navigationBar as hidden. Now you can add the above view with 44 height as a sticky one for all View controllers.
If you want a way to communicate between child view controllers under navagtion with the parent I would suggest NSNotification observer or a Delegation to be confirmed by all child VC or by a subclass of UINavigationController.
This is a sytematic way.
Other dummy way is to add a view to the window and set the view.layer.zPosition if you want it below or above any other view.

you can use Container View and show/hide other views

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

ContainerView nextViewController is not child stacked to container view as subview

I have 3 View Contorller
First View controller have Container View of height 300.0f at the center.
It has one embedded view Controller which is table View controller.
On cell selection it should navigate to detailsViewController.
All the process is ok.
But detailsViewController is not behaving as embedded view controller of containerView and not of same size as container view.
It takes whole screen size.
As it is triggered from the embedded View Controller it should follow that frame without overlapping other controls which are in First View Controller.
You need to embed not view controller with table view, but embed navigationController(you can hide navigation panel on up side), end set yours table view controller as root for it, and use pushViewController to go to detail page.
hope ganesh this will help you
Look You have a Container View inside it you have a tableView and By clicking an cell you pushing another viewController that what i concluded after reading your question(hope you done everything in modular way).
Now you must have UIView subclass(i.e separately creating a view class ) inside which you have a tableView so you pushing by
[self.nav pushViewController:sos animated:YES];
there are two way to push ViewController inside a view first by Callback(through blocks) or passing Navigation ref. in UIView Class .So you are pushing the new Controller over the navigation thats why it showing this behavior and which is obvious.

How do you change a master view controller from UITableViewController to UIViewController in a storyboard

I was wondering if it is possible to change the master view controller in a split view controller from UITableView to UIViewController in a storyboard. I am looking for a way to make the master view contain regular non scrolling controls on the top and left sides with a scrollable table view talking up the rest of the view space.
Delete the table view controller (and the navigation controller if you want), drag out a UIView controller, and hook it up (control drag) either to the split view controller or the navigation controller, if you're using that.

UIViewController as a subview for other view controllers

My app has a menu button which is available in every view controller. Every time a user taps on the menu button, a small menu pops up. The menu has multiple UIButtons, and each button links to another view controller.
My current solution is to create a view controller with a nib for the menu view and add it as a subview to each of the other main view controllers.
Is there is a better solution?
There could be multiple ways of doing it and I don't think there is the best answer.
However, in the performance perspective, implementing a view container such as UINavigationController or UITabBarController would be most effective.
Implement a root view controller (whose view is added as the only direct subview of the application window), and add the menu as a subview of its view. Let the root view controller decide (or know) which view to display, and add the view as a subview of its view, below the menu.
In this way, the view for the menu need not be removed and added again to the current view hierarchy.

Resources