一个界面,有多个滑动界面,然后用多个控制器控制这些滑动的界面




添加每个子控制器到主界面控制器

 [self addChildViewControl];

- (void)addChildViewControl {

    

    JHNewsViewController *newsVC = [[JHNewsViewController alloc] init];

    newsVC.title = @"新闻";

    [self addChildViewController:newsVC];

    

    JHPersonnelViewController *personneVC = [[JHPersonnelViewController alloc] init];

    [self addChildViewController:personneVC];

    

    JHRemindViewController *remindVC = [[JHRemindViewController alloc] init];

    [self addChildViewController:remindVC];

    

    JHScheduleViewController *scheduleVC = [[JHScheduleViewController alloc] init];

    [self  addChildViewController:scheduleVC];

    

}

添加一个scrollView,然后把每个子控制器的视图添加到上面

- (void)setupContentScrollView {

    

    UIScrollView *myScrollView = [[UIScrollView alloc] init];

    myScrollView.showsHorizontalScrollIndicator = NO;

    myScrollView.frame = CGRectMake(0, 64 + 50, ScreenWidth, ScreenHeigth - 64 - 50 - 50);

    myScrollView.pagingEnabled = YES;

    myScrollView.contentSize = CGSizeMake(self.childViewControllers.count * ScreenWidth, ScreenHeigth - 64 - 50 - 50);

    myScrollView.delegate = self;

    [self.view addSubview:myScrollView];

    self.contentScrollView = myScrollView;

    myScrollView.bounces = NO;

    [self scrollViewDidEndScrollingAnimation:myScrollView];

    

    JHNewsViewController *newsVC = self.childViewControllers[0];

    

    newsVC.view.frame = CGRectMake(0, 0, ScreenWidth, myScrollView.mj_h);

    [myScrollView addSubview:newsVC.view];

    

    JHPersonnelViewController *personnelVC = self.childViewControllers[1];

    personnelVC.view.frame = CGRectMake(ScreenWidth, 0, ScreenWidth, myScrollView.mj_h);

    [myScrollView addSubview:personnelVC.view];

    

    JHRemindViewController *remindVC = self.childViewControllers[2];

    remindVC.view.frame = CGRectMake(ScreenWidth * 2, 0, ScreenWidth, myScrollView.mj_h);

    [myScrollView addSubview:remindVC.view];

    

    JHScheduleViewController *scheduleVC = self.childViewControllers[3];

    scheduleVC.view.frame = CGRectMake(ScreenWidth * 3, 0, ScreenWidth, myScrollView.mj_h);

    [myScrollView addSubview:scheduleVC.view];

    

    

}

ok,就是这么简单,每天进步一点点

友情链接



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值