美文网首页
添加和移除子视图控制器(child ViewController

添加和移除子视图控制器(child ViewController

作者: Dorajimmy | 来源:发表于2017-02-08 00:00 被阅读0次

// add child viewController添加子视图

   UIViewController* controller = [self.storyboard instantiateViewControllerWithIdentifier:@"test"];

   [self addChildViewController:controller];

   controller.view.frame = CGRectMake(0, 44, 320, 320);

   [self.view addSubview:controller.view];

   [controller didMoveToParentViewController:self];

// remove child viewController删除子视图

   UIViewController *vc = [self.childViewControllers lastObject];

   [vc.view removeFromSuperview];

   [vc removeFromParentViewController];

相关文章

网友评论

      本文标题:添加和移除子视图控制器(child ViewController

      本文链接:https://www.haomeiwen.com/subject/ocxvittx.html