简体   繁体   English

UIScrollView在放大时以UIImageView为中心旋转?

[英]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. 我已经在UIScrollView中放置了一个UIImageView并设法处理了几乎所有东西,这就是如果我放大图像的一部分(例如肖像图像),然后在横向旋转设备,该部分显示为旋转在左上角而不是中心。

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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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