I have a UIScrollview with an IBOutlet mapped to ganttScroller. This UIScrollView has a UIView in it. I made the UIView in IB and its width is 100.
I then start to add buttons to that UIView (mapped via an IBOutlet scrollContent)
float test = [scrollContent frame].size.width;
for (int i=0; i<15; i++) {
UIButton *showButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
showButton.frame = CGRectMake(55.0 * i,
50.0,
50.0,
20.0);
[showButton setTitle:NSLocalizedString(@"test", @"") forStates:UIControlStateNormal];
[scrollContent addSubview:showButton];
}
test = [scrollContent frame].size.width;
[scrollContent sizeToFit];
test =[scrollContent frame].size.width;
At the beginning I check the size of my scrollContent and it is indeed 100 (checked 'test' in the debugger), after adding the buttons it is again 100, and after sizeToFit it is still 100 (I would expect a lot larger since all those buttons were added... The buttons are shown correctly! I need the correct size for my gantScroller (UIScrollView)
What is wrong ?