Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Mac Me Up

macrumors regular
Original poster
Jun 25, 2005
170
0
Australia
Ok, so I have a UIImageView in a UIView and I want them to be scrollable with my finger. I've made the image view multi touch capable and handled the
Code:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
method. In this method I simple set the center of my view and image to the location that corresponds to how far it tells me that the users finger has moved. This works fine, and you can move it up and down with no problems.

My question is: how do I make this 'springy' and smooth like Apple's scrolling of tables, where your flick has momentum and the view springs when it hits the end. Is there an easy way to do this or do I have to write all the code that handles this?

At the moment my view moves to exactly where your finger stopped and no more, which feels unnatural on the iPhone.
 

Mac Me Up

macrumors regular
Original poster
Jun 25, 2005
170
0
Australia
Sorry to be a N00b, but I've put my view in a UIScrollView and made that view multi touch enabled, then commented out my implementation of the move method. Now it doesn't scroll. I've looked at the documentation for the UIScrollView and it seems like it should just work?
 

Mac Me Up

macrumors regular
Original poster
Jun 25, 2005
170
0
Australia
Ok after smacking my head into a wall for a while I figured it out. I couldn't get it to work when I created the UIScrollView in Interface Builder, but as soon as I did it manually, hey presto!

Code:
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 440)]
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.