使用UIScrollView缩放布局框架中的图像 [英] With UIScrollView zoom images in layout frame
本文介绍了使用UIScrollView缩放布局框架中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经用Xcode创建了一个应用程序。
I have create an app in Xcode.
在我的应用中,我需要在uiscroll视图中具有多个图像的功能。
In my apps I require a functionality that has several images in uiscroll view.
我无法在滚动视图中缩放图像。我该怎么做?
I cannot zoom images in scroll view. How i do it?
推荐答案
将图像视图放入滚动视图,并在每个视图中启用用户交互以及多点触摸,现在
put your image view inside scroll view, and make user interaction as well as multiple touch enable in each, now
为滚动视图提供以下设置:
provide following setting to your scroll view:
//Pinch Zoom Stuff
imageScrollView.maximumZoomScale = 4.0;
imageScrollView.minimumZoomScale = 1.0;
imageScrollView.clipsToBounds = YES;
imageScrollView.delegate = self;
imageScrollView.scrollEnabled = NO;
然后实施以下方法:
- (void)scrollViewDidZoom:(UIScrollView *)scrollView
{
if (scrollView.zoomScale!=1.0)
{
// Not zoomed, let the scroll view scroll
imageScrollView.scrollEnabled = YES;
}
else
{
// Zooming, disable scrolling
imageScrollView.scrollEnabled = NO;
}
}
- (UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return imageView;
}
这篇关于使用UIScrollView缩放布局框架中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文