在主控制器里添加ScrollView,再添加入子控制器

//初始化scrollview

_vcScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0 ,0,  CYXwidth,CYXheight - 64 - 50)];

_vcScrollView.backgroundColor = [UIColor whiteColor];

_vcScrollView.pagingEnabled = YES;

_vcScrollView.bounces = YES;

_vcScrollView.showsHorizontalScrollIndicator = NO;

_vcScrollView.delegate = self;

[self.view addSubview:_vcScrollView];

_vcScrollView.contentSize = CGSizeMake(CYXwidth*5, 0);

ZMLatestViewController *firstV = [[ZMLatestViewController alloc]init];

[self addChildViewController:firstV];


//添加子控制器

ZMNewVersionViewController *twoV = [[ZMNewVersionViewController alloc]init];

[self addChildViewController:twoV];

ZMHeroCircleViewController *threeV = [[ZMHeroCircleViewController alloc]init];

[self addChildViewController:threeV];

ZMVideoViewController *fourV = [[ZMVideoViewController alloc]init];

[self addChildViewController:fourV];

ZMColumnViewController *fifthV = [[ZMColumnViewController alloc]init];

[self addChildViewController:fifthV];

[self scrollViewDidScroll:self.vcScrollView];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容