如何将图像数组添加到 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);