views:

75

answers:

1

Hi everyone.

I've been struggling with this for a while and have not found a solution.

I'm resizing a UIWebView using animations through beginAnimations: and commitAnimations. All goes well, except for when the resizing tries to make the UIWebView larger.

Let me make this clearer. Suppose the current frame of my UIWebView is (0, 0, 320, 300).

Then, I try to resize it to (0, 0, 320, 340) by using:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[self.webView setFrame:(CGRectMake(webView.frame.origin.x, webView.frame.origin.y, webView.frame.size.width, 340))];
[UIView commitAnimations];

By doing that, I expect the UIWebView to come down 40 pixels, but it actually goes up a little bit (around 10 - 20 pixels) and only AFTER THAT it comes down to the desired position (so it ends up coming down around 50 - 60 pixels, actually).

Does anyone know how to solve that? What I want to do is have the bottom of my UIWebView go down when the method is called, so if there are any other options for accomplishing it, I would be happy to try.

Thanks a lot.

A: 

Instead of animating the frame of the UIWebView, you should try animating the bounds alone, or perhaps the bounds and center together. e.g. expand the height by 40 while simultaneously moving the center down by 20.

hotpaw2
Animating the bounds AND the center actually works! There are just two things to notice: first of all, the up animation must also work with bounds and center. Otherwise, it still won't work after animating up. Secondly, while it works when the UIWebView is scrolled all the way down, it doesn't work at any other situation (The issue described early also only happens when the UIWebView is scrolled all the way down) Is there any way to detect where the UIWebView stands before calling the animation?
Aloha Silver