uiimageview里面uiscrollview位置不居中

发布于 2025-01-04 11:28:38 字数 296 浏览 3 评论 0原文

我正在使用 Objective C 为 iPhone/iPad 开发一个应用程序。在我的应用程序中,我有一个 UiScrollView,里面有一个 UIImageView。我可以滚动和缩放滚动视图内的图像。

一切正常。但我的问题是,当我在 uiscrollview 中加载图像时,它的位置位于中心位置,但不准确。

我希望我的图像应该居中对齐或位于左上角。

我已将 contentoffset 设置为 (0,0),并尝试将 AutoresizingMask 设置为不同的值。

如果有人有任何想法或解决方案,请告诉我。

I am developing an app for iPhone/iPad using Objective C. In my app I am having an UiScrollView which is having an UIImageView inside it. I can scroll and Zoom the Image inside the Scroll View.

All works fine.But my problem is that when I am loading the Image Inside a uiscrollview, its position is at something at center but not exactly.

I want that either my image should be center aligned or at the Top Left corner.

I had set the contentoffset to (0,0) and also tried setting the AutoresizingMask to different values.

Please let me know if somebody has any idea or solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由如风 2025-01-11 11:28:38

contentoffset 是滚动视图的一部分,可能不适合这种情况。如果您希望图像位于中心,请执行以下操作:

imageview.center = scrollview.center;

如果您希望图像位于滚动视图的左上角,请执行以下操作:

imageview.frame = CGRectMake(0,0,image_width,image_height);

祝您好运!

contentoffset is something of the scrollview and is probably not right for this situation. If you want the image to be in the center do this:

imageview.center = scrollview.center;

If you want the image to be at the top left corner of the scrollview do this:

imageview.frame = CGRectMake(0,0,image_width,image_height);

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文