我是iOS开发中的新手。我知道这个问题多次问过,但我没有得到答案。在这里,我将我的图像添加到一个UIImageview,然后将这个UIImageView添加到UIScrollView我为此编写代码,如
for(index=0; index < [self.imagesa count]; index++)
{
NSDictionary *dict=[self.imagesa objectAtIndex:index];
NSString *image=[dict valueForKey:@"link"];
bigImage=[[UIImageView alloc]init];
bigImage.userInteractionEnabled=TRUE;
bigImage.tag=123;
bigImage.tag=index;
bigImage.bounds=CGRectMake(0, 0, self.zoomScroll.frame.size.width, 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);
[self.zoomScroll addSubview:bigImage];
[bigImage setMultipleTouchEnabled:YES];
[bigImage sd_setImageWithURL:[NSURL URLWithString:image] placeholderImage:[UIImage imageNamed:@"1.png"]];
[bigImage setUserInteractionEnabled:TRUE];
[self.objectarray insertObject:bigImage atIndex:index];
CGSize scrollViewSize=CGSizeMake(self.zoomScroll.frame.size.width* [self.objectarray count], self.zoomScroll.frame.size.height);
[self.zoomScroll setContentSize:scrollViewSize];
[self.zoomScroll addSubview:[self.objectarray objectAtIndex:index]];
self.zoomScroll.scrollEnabled=YES;
self.zoomScroll.clipsToBounds=YES;
我写了一个像
一样的ViewforzoomInScrollview-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return bigImage;
}
这里我的Scrollview包含所有图像,但是当我缩放时,它仅缩放第一张图像和缩放后的滚动视图大小设置为固定而不是滚动。在这里,我将Scrollview的所有属性委托设置为MaximumZoomScale,MinimumZoomScale,但它在Scrollview中不缩放Curreent图像它始终首先Imageview的图像请给我解决方案。