How to switch between ViewController inside ContainerView? - iphone

I've added a container view inside another ViewController. From this, I dont really know how to do to swith between ViewController inside the ContainerView.
The container view:
The default ViewController inside the ContainerView (with storyboard id "firstView"):
I've a last ViewController (with storyboard id "secondView")
From this, how can I do to switch between firstView and secondView inside my Container View ? How can I get an outlet for the ContainerView, firstView and secondView ? If this is not the right way to dos this, can someone help me out to achieve what I want ?
(I already checked the apple's documentation and didn't find what I need :( )
Thanks :)

Just add the controller's view to the container view.
[controller.containerView addSubview: othercontroller.view]

Related

UITabbarViewController: Use StoryboardReferences

To have each tab content in it's own Storyboar I use storyboard references and configure the title and image in my viewcontroller.
I set the image and the title inside the viewDidLoad method in each viewcontroller. This has the problem that the TabbarItem is not displayed until I tab it, beacause the viewcontrollers are lazy loaded an not when the tabbbarController is loaded.
How can I improve this?
I would suggest you to take UINavigationController before your UIViewController's reference and make root view of that UINavigationController. By this way it will give you a tabbar item to configure in UINavigationController in storyboard.

ActionSheet with SegmentControl Swift 3

Is it possible implement SegmenControl in ActionSheet (UIAlertController) How can I do this? Thanks.
Example
Just another way of achieving the required functionality without the UIActionSheet:-
In your storyboard make a new UIViewController
Add a UITableView in your newly created UIViewController
Set Presentation to Over Current Context in the attributes of your ViewController
Change the Background color of your View in your ViewController to Clear
Create a Seague from the ViewController to your newly created View controller and set it to Present Modally.
Add the constraints to your UITableView that it covers half of the screen.

What is the Parent of a ViewController placed as SubView?

I have a ViewController where I have placed another ViewController on one of it's SubView. In that ViewController (placed in SubView) I need to go to another ViewController on a click event. But when I can self.navigationController pushViewController method , My log says It's pushed but Screen is not changing.
My attached image depicts the scene , Match Details is the host ViewController. White rectangle is a UIView , and the guest ViewController is placed within this white rectangular View. When I click on the round button (Click written) , then another ViewController should replace the Host ViewController.
It's a complex application , so pasting codes here should not be a good idea. Just a few explanation would help me a lot , I can fix the codes myself. Some some hint required about my mistake.
Thanks in advance for help.
When you add view of viewController as subview you need also register your viewController as child view controller for parentViewController.
Example:
UIViewController *mainVC = [UIViewController new];
UIViewController *childVC = [UIViewController new];
[mainVC addChildViewController:childVC];
[mainVC.view addSubview:childVC.view];
UIViewController *parentVC = childVC.parentViewController;
Here parentVC is mainVC.

edit label in viewcontroller before it is called( inside a storyboard)

So im using a storyboard for my app. how can i edit a label on another viewcontroller inside the storyboard before the viewcontroller(the one with the label) is called?
thanks in advance

How to add a UIViewController as a subview to a UIViewController(RootViewController)?

I have a UIViewController named LoginViewController, and it is a rootViewController in the AppDelegate. In the LoginViewController, I have two buttons: Login and Enroll.
When I tap Login, I assign a TabBarController as the rootViewController, then show the TabBarController. However, now I think I need to add another UIViewcController as a subview when I tap Enroll. I tried the following:
[self.view addsubview:viewcontroller.view];
But the problem here is My ViewController's view.top is pinned about 20 pixels below the top of the screen. I think there is an issue with the status bar, but I can't figure out how to fix it.
I think that I need to add my ViewController as a subview to the LoginViewController, then redirect from there to different views. Can someone please suggest other options?
Try to set frame to your enroll screen object then add it as a subview to loginview.
Ex:
[enrollViewcontroller.view setFrame:CGRectMake(0,0,320,440)];
[self.view addsubview:enrollViewcontroller.view];
You should not make a UIViewController a subview of another UIViewController's view. What you likely want to do if treat the subview as a normal UIView (if not both of those views) so that you only have one UIViewController on screen and it occupies the entire screen.
More here: How to add an UIViewController's view as subview
Instead of adding a UIViewController as a subview to another UIViewController, I have decided to present my ViewController as a ModalViewController using
[self presentModalViewController:myViewController animated:YES];