子控制器没有调整大小

时间:2015-12-17 12:03:09

标签: ios objective-c iphone

我正在使用xib并调整大小。但是我的观点中添加了视图。但不要根据宽度调整大小。请帮忙。我想在scrollview上添加。请帮助我第一次使用子视图控制器

Q1 *view1 = [[Q1 alloc]initWithNibName:@"Q1" bundle:nil];
Q2 *view2 = [[Q2 alloc]initWithNibName:@"Q2" bundle:nil];
Q3 *view3 = [[Q3 alloc]initWithNibName:@"Q3" bundle:nil];
Q4 *view4 = [[Q4 alloc]initWithNibName:@"Q4" bundle:nil];
Q5 *view5 = [[Q5 alloc]initWithNibName:@"Q5" bundle:nil];
Q6 *view6 = [[Q6 alloc]initWithNibName:@"Q6" bundle:nil];
Q7 *view7 = [[Q7 alloc]initWithNibName:@"Q7" bundle:nil];
Q8 *view8 = [[Q8 alloc]initWithNibName:@"Q8" bundle:nil];

[self addChildViewController:view1];
[self addChildViewController:view2];
[self addChildViewController:view3];
[self addChildViewController:view4];
[self addChildViewController:view5];
[self addChildViewController:view6];
[self addChildViewController:view7];
[self addChildViewController:view8];

- (void)viewWillAppear:(BOOL)animated {
    for (NSUInteger i =0; i < [self.childViewControllers count]; i++) {
        [self loadScrollViewWithPage:i];
    }

    _page = 0;
    [self.pageControl setNumberOfPages:[self.childViewControllers count]];

    UIViewController *viewController = [self.childViewControllers objectAtIndex:self.pageControl.currentPage];
    if (viewController.view.superview != nil) {
        [viewController viewWillAppear:animated];
    }

    self.scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * [self.childViewControllers count], 1);   
}

0 个答案:

没有答案