内容简介:1. 把子视图控制器的视图添加到父视图控制器并覆盖2. 把子视图控制器的视图添加到父视图控制器的指定容器视图,适当时机跳转作者:陈满iOS
1. 把子视图控制器的视图添加到父视图控制器并覆盖
-
添加子控制器
#pragma mark - 添加子控制器 - (void)addSubControllers{ [self addChildViewController:_childViewController]; [self.view addSubview:_childViewController.view]; [_childViewController.view mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.view); }]; }
2. 把子视图控制器的视图添加到父视图控制器的指定容器视图,适当时机跳转
-
添加子控制器
#pragma mark - 添加子控制器 - (void)addSubControllers { _childViewController = [[InfoViewController alloc] initWithNibName:NSStringFromClass([InfoViewController class]) bundle:nil]; [self addChildViewController: _childViewController]; _childViewController.sModel = self.sModel; }
-
跳转控制器
#pragma mark - 跳转控制器 - (void)gotoContentView [self.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)]; [self fitFrameForChildViewController:_childViewController]; //设置默认显示在容器View的内容 [self.contentView addSubview:_childViewController.view]; }
-
子VC的布局约束
#pragma mark - 子VC的布局约束 - (void)fitFrameForChildViewController:(UIViewController *)chileViewController{ CGRect frame = self.contentView.frame; frame.origin.y = 0; chileViewController.view.frame = frame; }
作者:陈满iOS
链接:https://www.jianshu.com/p/06e334efc46e
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- Swift 化的视图控制器展示
- React研习之旅(二):视图控制器-路由
- 系统学习iOS动画之四:视图控制器的转场动画
- 用 Swift 中的单向数据流来替代臃肿的视图控制器
- c# – 如何在多个应用程序中重用MVC3控制器/视图?
- iOS之导航返回上上个控制器或指定返回某个控制器
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Is Parallel Programming Hard, And, If So, What Can You Do About
Paul E. McKenney
The purpose of this book is to help you understand how to program shared-memory parallel machines without risking your sanity.1 By describing the algorithms and designs that have worked well in the pa......一起来看看 《Is Parallel Programming Hard, And, If So, What Can You Do About 》 这本书的介绍吧!