基于baseview中多个子viewcontroll切换
// // BaseVC.m // SmsSessions // // Created by Ken on 16/6/24. // Copyright © 2016年 ken. All rights reserved. // #import "BaseVC.h" @interface BaseVC () { UIView *curView; UIViewController *curviewControll; } @end @implementation BaseVC - (void)viewDidLoad { [super viewDidLoad]; self.title = @"精彩内容"; //可以是一个下啦列表,控制索引,显示第几个view UIView *viewButton = [[UIView alloc] initWithFrame:CGRectMake(0, 0, App_Frame_Width, APP_Frame_Height)]; [self.view addSubview:viewButton]; //展示区 curView = [[UIView alloc] initWithFrame:CGRectMake(0, 50, App_Frame_Width, APP_Frame_Height-50)]; [self.view addSubview:curView]; UIViewController *vc1 =[[UIViewController alloc] init]; UIViewController *vc2 =[[UIViewController alloc] init]; UIViewController *vc3 =[[UIViewController alloc] init]; [self addChildViewController:vc1]; [self addChildViewController:vc2]; [self addChildViewController:vc3]; [curView addSubview:vc1.view]; curviewControll = vc1; } - (void) pressViewControll:(NSInteger) index { UIViewController *vc = [self.childViewControllers objectAtIndex:index]; [self transitionFromViewController:curviewControll toViewController:vc duration:4 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{ } completion:^(BOOL finished) { if (finished) { // curviewControll = vc; 替换成新viewcontroll }else{ // curviewControll = oldViewController; 仍然是旧的viewcontroll } }]; } @end