基于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

  

转载于:https://www.cnblogs.com/zcw-ios/articles/5614624.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值