如何缩放 UIScrollView 的内容以适应
我的 iPhone 上的 UIScrollView 是 480x230,首次显示时内容是 972x230。我需要提供这样的功能:当用户双击 UIScrollView 时,内容会按比例缩放以适合 480x230 UIScrollView。当再次双击它时,它应该缩小回原始大小。
最好的方法是什么?我已经摸索了几个小时,并认为这会起作用......
[bodyClockScrollView zoomToRect:bodyClockScrollView.frame animated:YES];
但似乎什么也没有发生。
谢谢,任何为我指明正确方向的帮助将不胜感激。
My UIScrollView on the iPhone is 480x230 and the content is 972x230 when first displayed. I need to provide functionality where when the user double taps the UIScrollView the contents zoom to fit with the 480x230 UIScrollView proportionally. When the double tap it again it should zoom back out to it's original size.
What is the best way to do this? I have been fumbling for several hours with this and thought that this would work...
[bodyClockScrollView zoomToRect:bodyClockScrollView.frame animated:YES];
But nothing seems to happen.
Thanks, any help pointing me in the right direction would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要确保您设置为滚动视图委托的类实现了此方法:
}
You need to make sure the class you've set up as the scrollview's delegate implements this method:
}
使用 CGAffineTransform 我找到了一种方法来完成我想要的事情...
这非常有效,当我想将其缩小到默认大小和位置时,您只需调用...
Using CGAffineTransform I figured out a way to do what I want...
This works great and when I want to zoom it back out to the default size and position you simply call...