I have a scrollview in UIViewController and it is attached with contstraints with 0 constant to all 4 edges. I am doing this in viewDidLoad
and here is the method
but all view controllers that are added as child have wrong frames. I tried to call that method in viewDidLayoutSubviews then the scroll view didnt work properly.
How can I make the frames are calculated correctly?
Code:
if (self.allSizeModel != nil) {
[self setChildViewControllers];
}
and here is the method
Code:
- (void)setChildViewControllers {
topVC = [[MySizesTopShoeVC alloc]initWithNibName:mad:"MySizesTopShoeVC" bundle:nil];
topVC.view.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-55);
topVC.delegate = self;
[topVC.dataArray addObjectsFromArray:self.allSizeModel.Top];
[self addChildViewController:topVC];
[self.containerScrollView addSubview:topVC.view];
[topVC didMoveToParentViewController:self];
bottomVC = [[MySizesBottomVC alloc]initWithNibName:mad:"MySizesBottomVC" bundle:nil];
bottomVC.view.frame = CGRectMake(SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT-55);
bottomVC.delegate = self;
[bottomVC.dataArray addObjectsFromArray:self.allSizeModel.Bottom];
[self addChildViewController:bottomVC];
[self.containerScrollView addSubview:bottomVC.view];
[bottomVC didMoveToParentViewController:self];
shoeVC = [[MySizesShoeVC alloc]initWithNibName:mad:"MySizesShoeVC" bundle:nil];
shoeVC.view.frame = CGRectMake(2*SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT-55);
shoeVC.delegate = self;
[shoeVC.dataArray addObjectsFromArray:self.allSizeModel.Shoe];
[self addChildViewController:shoeVC];
[self.containerScrollView addSubview:shoeVC.view];
[shoeVC didMoveToParentViewController:self];
brandVC = [[MySizesBrandVC alloc]initWithNibName:mad:"MySizesBrandVC" bundle:nil];
brandVC.view.frame = CGRectMake(3*SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT-55);
brandVC.delegate = self;
[self addChildViewController:brandVC];
[self.containerScrollView addSubview:brandVC.view];
[brandVC didMoveToParentViewController:self];
brandVC.isFromProfile = true;
}
but all view controllers that are added as child have wrong frames. I tried to call that method in viewDidLayoutSubviews then the scroll view didnt work properly.
How can I make the frames are calculated correctly?