0
votes

I have a xib with a View, I changed the View class to be UIScrollView. Now I have set contentSize to some big number (2000, 2000).

Here is my code:

This allows talking to my scrollview without casting every time:

- (UIScrollView *)scrollView {
    return (UIScrollView *)self.view;
}

This I do in viewDidLoad:

self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 2600);
self.scrollView.scrollEnabled = YES;

I know viewDidLoad is getting called fine. But the scrollView is not reacting. I don't have any touch responders or anything that can absorb touches.

2
are you using auto-layout? - Mariam K.
@MariamN.nope, it is disabled and target is 5.0 - Dvole

2 Answers

2
votes

For this, first set delegate of scrollView inside your xib files then create an IBIoutlet for your scrollview. Remind that scrollView should connect with its refrencing outlet then Assign a propertyy as Strong to your scrollView.

  @property (strong, nonatomic) IBOutlet UIScrollView *scrollView;

and synthesize it.

  @synthesize scrollView;

then try to set contentSize.

 scrollView.delegate=self;
 scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 2600);
 scrollView.scrollEnabled = YES;

I hope it works for you.

0
votes

I have found a problem, I was setting superview too small.