I want to built a large view in IB and then add it to my scroll view. To do so, I have followed these instructions.
My view is correctly drawn in the scroll view, but it cannot scroll. I logged the content size and it's all correct: Content view size: 320.000000 x 714.000000
When I replace [self.view addSubview:self.contentView];
with
[self.view addSubview:[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)]];
the scroll view is, as expected, empty, but at least the scroll bars are shown and I can scroll. Is there's something wrong with my view in the nib file?
Here is my viewDidLoad
:
[super viewDidLoad];
[self.navigationController setToolbarHidden:YES animated:YES];
NSLog(
@"Content view size: %f x %f",
_contentView.frame.size.width,
_contentView.frame.size.height);
[self.view addSubview:self.contentView];
((UIScrollView *)self.view).contentSize = self.contentView.frame.size;
The only difference in my code is, that I have the scroll view inside a navigation controller. Does that make a difference?