Resizing a UIView with a Subtitle UIScrollView

Hey guys! I have a big problem with the change of the size obtained UIViewwith UIScrollViewboth rootstock.

in the message layoutSubviewsI set the frame of the UIScrollView sub-site. UIScrollViewcontains a UIImageViewwith a large image that can be moved / clamped and so on. initial contenSize UIScrollViewis the initial size of the image.

still so good. moving and pinching images work well. now I have to change the frame of the UIView (in my application to maximize the UIView). im does this in an animation block ( beginAnimations/ commitAnimations). so I set a new frame (which will update the width and height), and then call [myView layoutIfNeeded]to force UIScrollView to update its frame in the message of layoutSubviewsmy view.

animates UIViewits new frame, and if contentOffset UIScrollViewcurrently x 0, y 0, the frame UIScrollViewwill be updated properly. but here is my problem: if contentOffsetof UIScrollView more x 0, y 0 , it UIScrollViewwill “slide” in the upper left corner to the end position.

I want the UIScrollView to correctly modify its frame with the parent frames and align the content (in my case UIImageView). but how can i achieve this?

+3
source share
1 answer

after several studies on the internet, I found a solution to this problem:

[UIView setAnimationBeginsFromCurrentState: YES];

This will revive all layers from the current state.

+10
source

All Articles