views:

410

answers:

2

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.

A: 

As far as I understand what you've done in your project, what you are seeing is the normal behaviour of any scrolling window in iPhoneOS. That is, your UIWebView is wide enough to contain all the HTML content displayed within so while it will move when you drag it, it springs back to its original position when you let go. The fact that the UIWebView is wider than the screen due to the fact that you've rotated it, but not resized it, means that you can't see it all the HTML content, but as far as the UIWebView is concerned it's all visible so it doesn't let you properly scroll it, it just bounces.

U62
Thanks for the reply. Ignoring the manual rotation for the moment, I've noticed that if I re-orient the iPhone left or right that iPhone OS (because of resizing masks presumably) stretches the old 320 width to the new 480 width and then stretches the UIWebView downwards proportionately. And, this is key, if I then touch the UIWebView and pull it upwards the remainder comes into view *and* stays in view when I untouch it. So by default, it's doing exactly what I want -- I can manipulate any part of the UIWebView onto the screen and have it stay visible. I just don't know how it's doing it.
jarmod
A: 

Hey,I am also facing the same problem.After rotating theUIWebView from the landscape View, the content doesn't get fit in the portrait view. It means theUIWebView gets wider than its original size.

SoftProdigy