开发者

UIScrollView scroll when orientation changes

I create a UIScrollView, in which I put a UIView. Then I add some objects which are subviews of the view I added to the UIScrollView, so that I can zoom properly all the objects within the scroll.

The point is that I have an UIImageView as a subview of the mentioned view, which contains an image which is adapted to the screen size by using "imageView.contentMode = UIViewContentModeScaleAspectFit;" property.

Initially, in portrait orientation, the image fits with the screen width, so you can't scroll to left or right. When I change orientation to landscape, image fits with screen top and bottom. Then my problem. You can scroll up and down a little bit the image, as if it preserved some of the top and bottom padding from the portrait orientation. But, if I try to zoom out, as the min zoom I setted was 1,开发者_如何学C0, the image recovers its initial size. Then you can't zoom out anymore when the zoom scale is 1.0. The 'virtual' padding is gone! It seems as if it needed some kind of refresh. The same happens when I keep changing orientation for portrait and landscape. It only works correctly when app loads.

I tried setting "myUIScrollView.zoom = 1.0;" in "didRotateFromInterfaceOrientation" method (when the image was not zoomed) and it worked, the 'virtual' padding again was gone.

It seems that it needs a refresh once orientation changes.

Any clue about what I'm doing wrong?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜