实现滚动界面
父子控制器,
-(void)setupBottomScrollView { UIScrollView *bottomScrollView = [[UIScrollView alloc]init]; bottomScrollView.frame = CGRectMake(0,TitleViewH + 0.5 , ScreenWidth , ScreenHeight); bottomScrollView.scrollEnabled = YES; bottomScrollView.backgroundColor = [UIColor whiteColor]; bottomScrollView.showsHorizontalScrollIndicator = NO; bottomScrollView.showsVerticalScrollIndicator = NO; bottomScrollView.delegate = self; bottomScrollView.bounces = NO; bottomScrollView.pagingEnabled =YES; bottomScrollView.userInteractionEnabled = YES; bottomScrollView.contentSize = CGSizeMake(_titleArr.count * ScreenWidth, ScreenHeight); [self.view addSubview:bottomScrollView]; _contentScrollView = bottomScrollView; if (!_deviceInfoVc) { _deviceInfoVc = [[HWDeviceInfoVC alloc]init]; _deviceInfoVc.view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight); _deviceInfoVc.delegate = self; } if (!_alarmInfoVc) { _alarmInfoVc = [[HWAlarmInfoVC alloc]init]; _alarmInfoVc.view.frame = CGRectMake(ScreenWidth, 0, ScreenWidth, ScreenHeight); } if (!_actualTimeVc) { _actualTimeVc = [[HWActualTimeVC alloc]init]; _actualTimeVc.view.frame = CGRectMake(ScreenWidth * 2, 0, ScreenWidth, ScreenHeight); } [_contentScrollView addSubview:_deviceInfoVc.view]; [_contentScrollView addSubview:_alarmInfoVc.view]; [_contentScrollView addSubview:_actualTimeVc.view]; [self addChildViewController:_deviceInfoVc]; [self addChildViewController:_alarmInfoVc]; [self addChildViewController:_actualTimeVc]; /**--------根据_detailVcType类型判断优先显示哪一个View--------------**/ _contentScrollView.contentOffset = CGPointMake(_detailVcType *ScreenWidth , 0); }