0

I have seen examples of rotating a UIImageView on touch. I have a case where I'm supposed to rotate the UIImageView on scrolling the UIScrollView. The UIImageView is the content of UIScrollView. Any suggestions on this?

Fry
  • 6,235
  • 8
  • 54
  • 93
DesperateLearner
  • 1,115
  • 3
  • 19
  • 45

1 Answers1

0

set the delegate to scroll view and call this method:

– scrollViewWillBeginDragging:

Inside of that rotate the imageview:

imgView.transform = CGAffineTransformMakeRotation(1.57079633); //90 degrees

then set it back when

– scrollViewDidEndDecelerating:

imgView.transform = CGAffineTransformMakeRotation(-1.57079633); //90 degrees
mkral
  • 4,065
  • 4
  • 28
  • 53
  • The imageview is a wheel. So is it possible to keep rotating until the scrollView decelerates? – DesperateLearner Sep 18 '12 at 15:49
  • What kind of wheel? Like a prize wheel or just a spinning icon? – mkral Sep 18 '12 at 15:50
  • Either way, this answer should work from what your question says. If you've seen the examples for rotating on touch. Just use scrollViewWillBeginDragging to call [self startSpinning:imgView]; and didEndDecelerating to call [self stopSpinning:imgView]; – mkral Sep 18 '12 at 15:54
  • the wheel is a car tyre rotation. just a normal rotation. not like the wheel of fortune – DesperateLearner Sep 18 '12 at 16:00
  • I haven't tested this but it seems like others like this way of spinning a uiview: http://stackoverflow.com/a/518620/879119 – mkral Sep 18 '12 at 16:32