简体   繁体   中英

UIScrollView with UIImageView centered rotation when zoomed?

I'm trying to create an image viewer that behaves exactly like the Apples Photo App. But for now I'm only interested in a single image behavior.

I've placed an UIImageView inside UIScrollView and managed to handle pretty much everything beside one thing, and that is if I zoom-in in a portion of image(for example a portrait image) and then rotate the device in landscape the portion appears to be rotated over the upper left corner instead of center.

Let me try to illustrate that. This is what I have now:

是)我有的

This is what I would want to happen:

我想要的是

Basically I believe I know how I could do it but it seems to involve a bit more coding than it probably deserves. Maybe I'm missing some simple property that I could just set to get this desired behavior.

Any hint, anyone?

self.imageView.center = self.scrollView.center;

设置[imgView setContentMode:UIViewContentModeScaleAspectFit];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM