Bhushan B
Bhushan B

Reputation: 2510

UIScrollView not scrolling in ios6

In my UIViewController I have a UIScrollView and UIView. These are two different view, means UIView is not inside UIScrollView. I have different view on scrollview that i am setting programmatically and increasing contentSize. And this UIView is hidden, i am showing is sometimes. The problem is that when i hide this UIView, that UIScrollView stops scrolling.

Why this happening?

I have set all leading edges to superview of both. Does it matter? Please guide me.

Hi all, I am sharing the image of my ViewController Sceneenter image description here

I am using auto layout (iOS6). Scroll View ContentSize is (768,1400) which i am setting in ViewDidAppear. The View below Scroll View is hidden and Scroll View is scrolling without any problem.

Now if i show and hide the View, the Scroll View locks, its not scrollable now. That is problem i am facing. I am not doing anything in code more than setting content size. If you need any other information, please tell me.

Upvotes: 3

Views: 4448

Answers (3)

mikemike396
mikemike396

Reputation: 2495

Remove all your code related to sizing the scrollview content size. Autolayout uses this while you are scrolling now. After you do this add the following code

// Add 200 points to the bottom of the scroll view
[self.scrollView setContentInset:UIEdgeInsetsMake(0, 0, 200, 0)];
self.scrollView.translatesAutoresizingMaskIntoConstraints= NO;

Upvotes: 5

Luke
Luke

Reputation: 14138

The contentSize in iOS 6 "auto-sizes" itself with auto layout. This means you cannot set the contentSize. There are hacks that suggest setting it in the viewDidAppear call, but I would avoid this. If you read the iOS 6 release notes (search for UIScrollView on the page) it gives you a couple solutions. One of them involve the translatesAutoresizingMaskIntoConstraints property.

Upvotes: 6

Jeremy
Jeremy

Reputation: 9030

Without any code, I'll hazard a guess...

This would be typical in a case if your contentSize doesn't exceed the size of your UIScrollView. If you were to, say, hide your view, then change the size of your scroll view and your scroll view exceeds or is equal to your contentSize, then you will not have anything to scroll.

Another possibility is if you have disabled user interaction.

Upvotes: 0

Related Questions