Segue
既不是Push
跳转而不是Model
跳转,而是Embed
嵌入的形式UIContainerview
这个类,它的本质其实就是一个UIView
UIView
的一个Category分类#import "ViewController.h" #import "SecondViewController.h" @interface ViewController () @property (weak, nonatomic) IBOutlet UIView *containerView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [self addContainerView]; // Do any additional setup after loading the view, typically from a nib. } - (void)addContainerView { //1.建立containerView目标控制器 SecondViewController *second = [[SecondViewController alloc] init]; //设置背景颜色 second.view.backgroundColor = [UIColor greenColor]; //2.将目标控制器的视图赋值给容器视图(不能用addSubView,不然设置frame无效) self.containerView = second.view; //设置显示大小 self.containerView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height-200); //3.添加到当前视图 [self.view addSubview:self.containerView]; //4.获取到Containerview的目标控制器 NSLog(@"%@",self.containerView.nextResponder); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
UIContainView是iOS系统中很是特殊的一个控件,它的主要特色以下:ios
UIContainerview
,代码中没有这个类 UIContainerview的原理markdown