0
votes

I am attempting to make a facebook/youtube-like slide-out menu for my app. My main view controller has two UIViews, one for the menu tableview and those, and one where I plan to contain whatever view the user has switched to.

I tried to make another UIViewController view made in interface builder as a subview contained in the UIView for content. I did that like this

[self.contentViewLayer addSubview:[[PersonViewController alloc]init].view]; with and without the .view at the end. It didn't work. Is it possible to have a UIViewController from storyboard contained in a UIView?

2
Might I suggest a class from github? github.com/gotosleep/JASidePanels I use this for my app, its fantastic!heinst
Yes, if you are just looking for a side panel effect, there are many on GitHub that should work well for you.Christian Di Lorenzo
@heinst Looks neat, thanks. I'll check it out and try to make it work.Oscar Apeland

2 Answers

1
votes

You should probably take a look at Child View Controllers from the Apple documentation.

Here's some code that exemplifies this technique:

- (void)addContentViewController:(UIViewController *)viewController {
  /* This should be inside your slide out view controller manager */
  [self addChildViewController:viewController];
  viewController.view.frame = [self frameForContentController];
  [self.view addSubview:viewController.view];
  [viewController didMoveToParentViewController:self];
}
1
votes

You can use a container view:

[self addChildViewController:vc2];
[self.container addSubview:vc2.view];

Or you can do [vc1.view addsubview:vc2.view];