Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Moving a scroll view

I have the following piece of code that moves a scroll view on the click of a button. [scrollView setContentOffset:CGPointMake(320, 660) animated:YES]; Am I able to change this piece of code to move down to "660" on the Y axis but not change the X?

1 Answer

[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, 660) animated:YES];

Brilliant. Thanks

Sorry. How would I change it so that it will minus 100 from the y value rather than set a new y value?

[scrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, scrollView.contentOffset.y - 100) animated:YES];

Sorry to bother you again, how would I pus this into a swipe gesture?