Rotating UIWebView with transform, content partially off screen, how to get it to stick on screen?

Posted by jarmod on Stack Overflow See other posts from Stack Overflow or by jarmod
Published on 2010-02-11T23:00:06Z Indexed on 2010/04/28 16:13 UTC
Read the original article Hit count: 271

Filed under:
|

I have a 320x416 portrait-shaped UIWebView filling a UIViewController's view. I also have a 90 degree rotate button that will transform the UIWebView through 90 degrees each time the button is touched. The code is basically:

webView.transform = CGAffineTransformMakeRotation(touches%4 * M_PI/2.0);

After rotation through 90 degrees, the now-landscape transformed UIWebView extends beyond both the left and right edges of the screen. In the process of applying the transformation, iPhone OS has changed the UIWebView's frame from {{0,0}, {320,416}} to {{-48,48}, {416,320}}. Don't have a problem with that.

I then tweak the UIWebView's frame origin to (0,0) so that it starts top-left, but extends a little further beyond the right edge of the screen. Now, I can touch the UIWebView and pull it left to view the hidden information on the right but I cannot get the right-hand end to to stay on the screen -- the moment I untouch it, the right side bounces back off the screen.

What is it that causes the view to bounce back off-screen? In other words, what is it that I need to tweak to allow either the left edge or the right edge to stick on the screen and remain visible (only one at a time, obviously)?

Thanks.

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about uiwebview