Adding a viewControllers view to another viewController

I am completely unfamiliar with the development of the iPhone. I have two ViewControllers

  • ViewControllerA
  • ViewControllerB

ViewControllerA is the first and is launched using the application.

I have another ViewControllerB, now I want to add the ViewControllerB view as a view in the ViewControllerA view when the application starts.

+3
source share
7 answers

try it

ViewControllerB *vcb = [[ViewControllerB alloc] init];

[self.view addSubview:vcb.view];
+10
source

Belated response. I just wrote a few words about my decision on this. It can be found here: http://blog.nguyenthanhnhon.info/2014/04/how-to-add-viewcontrollernavigationcont.html

+2

VC . .

@interface ViewControllerA()

{

ViewControllerB *viewControllerBObj;

}

- (void) viewDidLoad

{

[super viewDidLoad];

viewControllerBObj = [[ViewControllerB alloc]initWithNibName:@"ViewControllerB" bundle:nil];


[self.view addSubview:viewControllerBObj.view];

}

+1

, view. myControllerA myControllerB, B- A, .

[myControllerA.view addSubview:myControllerB.view];
0

[self.view addSubView:ViewControllerB.view] viewDidLoad() ViewControllerA.

0

. , , Interface Builder. !

0

in the "viewDidLoad" method of "ViewController1"

ViewController2 * vc2 = [self.storyboard instantiateViewControllerWithIdentifier: @ "ViewController2"]; [self addChildViewController: setting]; [self.view addSubview: setting.view];

0
source

Source: https://habr.com/ru/post/1794424/


All Articles