Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertical scrolling not working in UIScrollView and iOS7 and Xcode 5 despite not using Autolayout

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.

like image 217
Blaszard Avatar asked Jan 09 '14 08:01

Blaszard


3 Answers

onOffScroll.contentSize = CGSizeMake(content width,content height);

Use the viewDidLayoutSubviews method and use the code in this method. It may help you.

like image 63
vikrant tanwar Avatar answered Sep 21 '22 16:09

vikrant tanwar


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.

like image 31
Mani Avatar answered Sep 22 '22 16:09

Mani


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.. :)

like image 29
Rashad Avatar answered Sep 20 '22 16:09

Rashad