ContainerView nextViewController is not child stacked to container view as subview - ios

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.

Related

Xcode Storyboard: Can't add View to ViewController

I'm using Xcode 10 (with Swift 5 and for iOS 12) and my app is currently set up like this:
UIViewController 1 (login screen) - segue12 to ->
NavigationController that automatically created
UIViewController 2 with a UITableView - segue23 to ->
UIViewController 3 (detailed info about an item in the UITableView with automatically created "back" button)
The NavigationBar only contains a " ".
I now want to add another UIView with a button below the UITableView but Xcode won't let me drag it below the UITableView, only either into the UITableView or directly underneath "First Responder", which puts the View outside into its own window.
If I delete "My Table View", it won't let me drag in a replacement either.
How do I fix this, so I can add the new UIView + UIButton?
NavigationController that automatically created UIViewController 2
That explains everything. When you drag a navigation controller into the storyboard, what you get is a navigation controller and its root view controller, and the root view controller is a UITableViewController.
Let's step back for a moment. A view controller can and must have exactly one main view. It occupies the whole scene. It cannot be resized. It cannot have a sibling view, because it has no superview for a sibling view to be a child of. It can only have children (subviews).
Well, in this case, ViewController2 is a UITableViewController, and MyTableView is ViewController2’s main view. (A table view controller is always configured this way, and that is what you got when you dragged the navigation controller into the storyboard.) That is why you cannot add more views to it, except as subviews, e.g. prototype cell contents. Your button has no place to go except inside the table view.
So, what to do?
If the extra interface you want to add is just a button, the usual solution is to put it into the navigation bar. It becomes part of the table view controller's navigation item.
If you don't want to do that — that is, if you really want the button and the table view to be siblings of one another in the interface — then you need to replace ViewController2 itself with an ordinary view controller. Now its main view will be an ordinary view, and you can drag anything you like into it, including a table view and a button. More likely, instead of a bare table view, you would use a container view, with an embed segue to a table view controller.

NavigationController with sticky view at top

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

Can I use storyboard to embed UINavigationController's view inside a UIViewController?

I want to keep the top and bottom sections of my view stationary and I only want to add a navigation controller at the center of the screen.
This has been perfectly doable for a lot of years and now as everyone is so enchanted by the Storyboards, I wanted to do the same through the storyboard and it seems like it is impossible.
Is it possible anyways?
you can use Container View in the storyboard.
Container View defines a region within a view controller's view
subgraph that can include a child view controller. Create an embed
segue from the container view to the child view controller in the
storyboard.

iOS - Change title for top bar in a viewcontroller that is connected to a cell in a view container

So i have a main ViewController which is connected before to a navigator controller.
in my main view controller i have a ViewContainer and inside the container i have a table view (cells), now i want to connect each cell to a different View Controllers, and each of the view controllers to have a different title!!
when i make a (push) connection between a cell and a view controller, the view controller gets the title of my main view controller which contain the view container which contain the cell!!
please help, how to change the top bar title??
thank you very much.
UIViewControllers have a title property that you can edit. Add something like this:
[self setTitle:#"WhateverTitle"];
to the viewDidLoad method of your new UIViewController.

iOS: Keeping UIToolBar on top during segue

I have a UIViewController which segues (push) to another UIViewController. The first controller contains a nicely laid out UIToolBar menu and I want this to persist over the secondary UIViewController (and another other ones I push on the navigation stack).
Is this possible?
This can be done with a container view in a storyboard, or using the custom container view controller api in code. In the storyboard, you can add your tool bar to a view controller, drag in a container view, and size it to take up the rest of the view. You will automatically get a view controller connected with an embed segue to the container view. Select it, and embed it in a navigation controller. You can use prepareForSegue (which will be called immediately after your main view controller - the one with the container view - is instantiated) to get a reference to the navigation controller (it will be the destinationViewController).

Resources