开发者

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

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 th开发者_如何学JAVAe 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜