Cocoa Dev
Cocoa Dev

Reputation: 9551

UIScrollView not working with [scrollView setScrollEnabled: YES]

In my .h file, I have an IBOutlet declared like this:

IBOutlet UIScrollView *scrollView;

I wired my UIScrollView to File's Owner.

In my .m file I have the following in viewDidLoad:

[scrollView setContentSize:CGSizeMake(320, 600)];
[scrollView setScrollEnabled:YES];

But when I try to scroll, nothing happens.

You don't need to set the UIScrollViewDelegate because I've had apps that scroll without using it.

Upvotes: 0

Views: 2003

Answers (2)

user1066642
user1066642

Reputation: 125

If you have taken scroll view in xib file then you do not need to below line:

[scrollView setScrollEnabled:YES];

Also you should check your connection with file's owner.

Upvotes: 0

Andreas Ley
Andreas Ley

Reputation: 9345

If you a are using iOS 6, using Autolayout in your .xib files can be the reason that your UIScrollView doesn't behave the way you expect it to (even though your setting a large contentSize).

You can disable Autolayout by selecting the respective .xib file in the Project Navigator and unchecking "Autolayout" in the File inspector (in the right column).

You can also adjust your Autolayout settings (there's various threads on this).

Upvotes: 1

Related Questions