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)];
[scro开发者_如何学JAVAllView 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.
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).
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.
精彩评论