When I tried to use UIScrollView in iOS 7 and Xcode 5, it doesn't respond to vertical scrolling. I first drag and drop ScrollView from object library to storyboard and set its size as width = 320 and height = 1500, and then drag and drop three labels, and locate those labels at y = 300, 800, 1200. For labels whose y coordinate being equal to 800 and 1200, I first move scrollview to the upper to make those objects located at the corresponding y values. Then, I connect scrollview to implementation file as outlet, and in viewDidLoad
method, I write self.myScrollView.contentSize = CGSizeMake(320, 1500)
. And finally set back the size of scrollview at width = 320 and height = 568.
And then run the simulator, but it doesn't react to vertical scrolling. Then I deselected use autolayout
and run the simulator again, it's still not working at all.
So how can I fix the issue? Or can anyone inform me of any useful tutorials which teach about UIScrollView in iOS 7 and Xcode 5 (this is important, since every tutorial I've read is based on the prior version)?
I use Xcode 5.0.2.
Thanks.
onOffScroll.contentSize = CGSizeMake(content width,content height);
Use the viewDidLayoutSubviews
method and use the code in this method.
It may help you.
You have to set scrollview height as screensize or less than contentsize.
Then only it will scroll vertically.( contensize > scrollview.height) And check bool vairable scrollEnabled
set as YES
.
Set x = 0 and y =0, You have to set the content size to (320,1500), not x and y. x and y defines the starting location of scroll view not the content size. For content size:
self.scrollView.contentSize = CGSizeMake(320, 1500);
Hope this helps.. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With