如何将图像数组添加到 UIScrollView? [英] How to add an Image array in to UIScrollView?

查看:34
本文介绍了如何将图像数组添加到 UIScrollView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 iOS 开发的新手,我制作了一个包含 ScrollView 的应用程序,并在 scrollview 中添加了一个数组图像,但它不起作用.

i am newbie in iOS Development i make an Application that contain ScrollView and i add an array images inside scrollview but it is not working.

我为此写了一个代码

for(int index=0; index < [self.imagesa count]; index++)
{
    NSDictionary *dict=[self.imagesa objectAtIndex:index];
    NSString *image=[dict valueForKey:@"link"];
    UIImageView *bigImage=[[UIImageView alloc]init];
    bigImage.bounds=CGRectMake(0, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);
    bigImage.frame=CGRectMake(0, 0, self.zoomScroll.frame.size.width, self.zoomScroll.frame.size.height);
    [bigImage sd_setImageWithURL:[NSURL URLWithString:image] placeholderImage:[UIImage imageNamed:@"1.png"]];
    [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:bigImage];
    [self.zoomScroll addSubview:[self.objectarray objectAtIndex:index]];
}

它是在一个图像视图中添加我的所有图像.不是 Scrollview 中的一个一个,请给我解决方案

it is add my all images in one imageview. not a one by one in Scrollview please give me solution for that

这里的对象数组是 NSMutableArray 数组,imagesa 也是 NSMutableArray 并且它包含图像 URLlink.

Here object array is NSMutableArray array and imagesa is also NSMutableArray and it is contain image URLlink.

推荐答案

查看bigImage.frame"的 X 坐标.您在相同的坐标上添加图像,一个在另一个上.应该是...

See the X co-ordinate of your "bigImage.frame". Your adding images on same co-ordinates, one over the other. It should be...

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

这篇关于如何将图像数组添加到 UIScrollView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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