更新UIScrollView的zoomScale [英] Updating zoomScale of UIScrollView

查看:51
本文介绍了更新UIScrollView的zoomScale的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建了一个动画来放大或缩小UIScrollView,但是我的问题是zoomScale没有更新.例如,我使用创建的动画将UIView缩小到UIScrollView内,但是当我使用展开手势放大时,UIView将自动更改为大尺寸或放大尺寸.我看到我的zoomScale没有更新,仍然是1.0比例.然后在动画之后更新我的zoomScale,但问题是缩小的UIView将自动转到屏幕顶部.我可以更新UIScrollView的zoomScale属性吗?

I just created an animation to zoom in or zoom out a UIScrollView, but my problem is that the zoomScale is not updating. Like for example, I zoom out my UIView inside of my UIScrollView using the animation I created, but when I zoom in using expand gesture the UIView will automatically change to its big size or zoom in size. I saw the my zoomScale is not updating and still in 1.0 scale. Then I update my zoomScale after the animation but the problem is the zoom out UIView will automatically go to the top of the screen. Can I update this zoomScale property of UIScrollView?

谢谢.

推荐答案

您是否实现了viewForZoomingInScrollView函数?更改zoomScale时,将调用滚动视图委托的此功能.它返回更改滚动视图的比例时必须重新缩放的视图.通常,您只需返回参数中给出的scrollView即可:

Did you implement viewForZoomingInScrollView function ? This function of your scroll view delegate is called when you change the zoomScale. It returns the view that must be rescaled when the scale of your scrollview is changed. In general you just return the scrollView given in parameters :

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView; {
    return scrollView.childView;
}

别忘了为您的滚动视图设置一个委托: yourScrollView.delegate = self;

Don't forget to set a delegate to your scrollview : yourScrollView.delegate = self;

这篇关于更新UIScrollView的zoomScale的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆