简体   繁体   English

按下“缩放”按钮时如何缩放Scrollview的图像?

[英]How to Zoom Image of Scrollview when Zoom Button was Pressed?

i am newbie in iOS Development i want an image gallery with UIScrollview and i want to Zoom an image when Zoom Button Was pressed initial my Scrollview Size like as 我是iOS开发的新手,我想要一个带有UIScrollview的图像集,并且我想在按“缩放”按钮时按如下所示缩放图像:

self.zoomScroll.frame=CGRectMake(10, 45, 300, 270);

and i add a Zoom Button in a My View When it is Pressed i set Scrollview Size as 当我按下“我的视图”时,我在其中添加了“缩放”按钮

self.zoomScroll.frame=CGRectMake(10, 40, 300, 400);

then scrollview is Shown in new Size but the image inside the Scrollview is in initialSize means image not take a new Size. 然后滚动视图将以新大小显示,但滚动视图中的图像处于initialSize表示图像未采用新大小。 and my image view Size is like as 我的图像视图大小就像

bigImage.bounds=CGRectMake(0, 0, self.zoomScroll.frame.size.width +10.0f, self.zoomScroll.frame.size.height);
bigImage.frame=CGRectMake(index * self.zoomScroll.frame.size.width, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);

and here my imageview is not a globally declared it is locally declare so i am not able to use scrollviewZoom method please give me solution for Zoom an image when Zoom button pressed. 而且这里的imageview不是全局声明的,而是局部声明的,因此我无法使用scrollviewZoom方法,请在按下“缩放”按钮时为我提供“缩放图像”的解决方案。

Please check if this is useful for you, as for my app requirement I am using this. 请检查这是否对您有用,因为我正在使用我的应用程序要求。

First thing if you are adding imageViews into scrollView, then before adding each imageView into scrollView set the value for tag property of each imageView it is ok if you set same value for tag property of all the imageViews you are going to add in scrollView. 首先,如果要将imageViews添加到scrollView中,则在将每个imageView添加到scrollView中之前,为每个imageView的tag属性设置值是可以的,如果为要在scrollView中添加的所有imageViews的tag属性设置相同的值,就可以了。

Then add UIScrollView's delegate method as follows and check, 然后按如下所示添加UIScrollView的委托方法并检查,

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 
{
    return [scrollView viewWithTag:<valueOfTagPropertySetToImageView>];
}

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

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