I have setup a viewcontroller using storyboard + autolayout, however I am having some problems (re)sizing a subview correctly for 3.5"/4" display.
This is what I have setup in storyboard:
The scrollview correctly keeps its 20px space to the bottom according to the constraint. However the subviews (red), which I add in the below loop to the scrollview should have the same height as the scrollview, but they don't :(
int pageCount= 3;
self.scrollView.delegate= self;
self.scrollView.pagingEnabled= YES;
self.scrollView.scrollEnabled= YES;
self.scrollView.showsHorizontalScrollIndicator= NO;
self.scrollView.showsVerticalScrollIndicator= NO;
self.scrollView.contentSize= CGSizeMake(self.scrollView.bounds.size.width * pageCount, self.scrollView.bounds.size.height);
NSLog(@"viewcontroller frame: %@ (bounds: %@)", NSStringFromCGRect(self.view.frame), NSStringFromCGRect(self.view.bounds));
NSLog(@"scrollview frame: %@ (bounds: %@)", NSStringFromCGRect(self.scrollView.frame), NSStringFromCGRect(self.scrollView.bounds));
NSLog(@"scrollview content size%@", NSStringFromCGSize(self.scrollView.contentSize));
for (int i= 0; i < pageCount; i++)
{
UIView* neutralContainer= [[UIView alloc] initWithFrame:CGRectMake(0.0 + i * self.scrollView.frame.size.width, 0.0, self.scrollView.frame.size.width, self.scrollView.frame.size.height)];
neutralContainer.backgroundColor= [UIColor redColor];
NSLog(@"containerview frame: %@ (bounds: %@)", NSStringFromCGRect(neutralContainer.frame), NSStringFromCGRect(neutralContainer.bounds));
[self.scrollView addSubview:neutralContainer];
As it seems, the scrollview frame i print in console (see screenshot) remains the same, no matter if i start the 4" or the 3.5" simulator. i would expect to get different values.
Can someone explain to me what i am doing wrong?