Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在UIScrollView中添加图像数组?_Ios_Objective C_Uiscrollview - Fatal编程技术网

Ios 如何在UIScrollView中添加图像数组?

Ios 如何在UIScrollView中添加图像数组?,ios,objective-c,uiscrollview,Ios,Objective C,Uiscrollview,我是iOS开发的新手,我制作了一个包含ScrollView的应用程序,并在ScrollView中添加了一个数组图像,但它不起作用 我为此编写了一个代码 for(int index=0; index < [self.imagesa count]; index++) { NSDictionary *dict=[self.imagesa objectAtIndex:index]; NSString *image=[dict valueForKey:@"link"]; UI

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

我为此编写了一个代码

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]];
}
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]占位符图像:[UIImage ImageName:@“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];
}
它是在一个imageview中添加我的所有图像。在Scrollview中不是一个接一个的,请给我解决方案


这里的对象数组是NSMUTABLEARRY,imagesa也是NSMUTABLEARRY,它是contain image URLlink

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

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

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

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

thnx bro但我想在图像之间留一个空间,怎么可能?#RoHaN还向我的大图像添加了一个UIPangestureRecognitor和UIPinchgestureRecognitor,然后它就不工作了。对于空间,只需在x坐标上增加一些开销。大约10.0f。“bigImage.frame=CGRectMake(index*self.zoomScroll.frame.size.width+10.0f,0,self.zoomScroll.frame.size.width,self.zoomScroll.frame.size.height);”你能给我看看手势识别器的代码吗,你尝试过什么。现在我想在按下按钮时缩放UISCrollView,这是怎么可能的?thnx bro,但我想在图像之间留一个空间,这是怎么可能的?#RoHaN,我还向我的大图像添加了一个UIPangestureRecognitor和UIPinchgestureRecognitor,但它不起作用。对于空间,只需在x坐标上增加一些开销。大约10.0f。“bigImage.frame=CGRectMake(index*self.zoomScroll.frame.size.width+10.0f,0,self.zoomScroll.frame.size.width,self.zoomScroll.frame.size.height);”你能给我看一下手势识别器的代码吗,你试过什么了。现在我想在按下按钮时缩放UISCrollView,这是怎么可能的?