Example code in "Adding a Child View Controller to Your Content" is a bit complicated and not 100% correct
| Originator: | konstantin.koval1 | ||
| Number: | rdar://25215135 | Date Originated: | 17-Mar-2016 12:50 PM |
| Status: | Open | Resolved: | |
| Product: | Documentation | Product Version: | |
| Classification: | Enhancement | Reproducible: | Always |
Summary:
The step N2 in documentation says -
“2. Add the child’s root view to your container’s view hierarchy.”
But the code shows this( which is not correct example):
[self.view addSubview:self.currentClientView];
It should be like this:
[self.view addSubview: content.view];
Full Code.
Code Now
- (void) displayContentController: (UIViewController*) content {
[self addChildViewController:content];
content.view.frame = [self frameForContentController];
[self.view addSubview:self.currentClientView];
[content didMoveToParentViewController:self];
}
Correct code
- (void) displayContentController: (UIViewController*) content {
[self addChildViewController:content];
content.view.frame = [self frameForContentController];
[self.view addSubview: content.view];
[content didMoveToParentViewController:self];
}
Link
https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html#//apple_ref/doc/uid/TP40007457-CH11-SW12
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!