1
votes

I have a UIScrollView with 2 UIImageViews inside. The images have a height of about 2330 pixels if you add them up.

In the Storyboard (iPad) I set the the UIScrollView size to width 768 and height to 1024.

Inside the viewDidLoad of the ViewController I set the contentsize of the UIScrollView programmatically like so:

- (void)viewDidLoad
{

[super viewDidLoad];

    [self.introScrollView setScrollEnabled:YES];
    self.introScrollView.contentSize=CGSizeMake(768,4500);

}

with a height of 4500 pixels which is more than enough for both images to fit. The funny thing is that it worked once and then stopped working again!!! How is it possible that it works and then stops again. It is not logical. It must a bug or something.

2

2 Answers

0
votes

First most common cause is contentSize, which you've handled.

Second most common cause is the outlet isn't set NSLog(@"%@",self.introScrollView); should not be nil. If it is, then you're not ever getting the chance to set contentSize.

A distant third is userInteractionEnabled on the scroll view has been set to NO in IB or elsewhere.

A distant fourth is a gestureRecognizer on a parent or overlapping sibling is stealing the gestures.

I'd wager on #2 in this case.

0
votes

I turned off AutoLayout in the IB for the UIScrollView which automatically deleted the constraints for the UIImageViews and now it works like a charm!