Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/13.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
Iphone 如何在imageview中添加图像数组_Iphone_Arrays_Image - Fatal编程技术网

Iphone 如何在imageview中添加图像数组

Iphone 如何在imageview中添加图像数组,iphone,arrays,image,Iphone,Arrays,Image,当我点击下一个按钮时,这个方法会被调用,但当我点击下一个按钮时,图像应该会改变,但在这里我没有得到下一个图像, 请帮帮我 提前感谢您您已将所有图像放入一个数组中。因此,设置一个计算单击次数的变量。每当您单击按钮时,只需将var计数增加1,并将该数组索引图像设置到imageview中……我认为您必须编写以下代码才能更改图像 -(IBAction)btnNextTapped { self.currentPhotoIndex++; if([allPhotosArray count]

当我点击下一个按钮时,这个方法会被调用,但当我点击下一个按钮时,图像应该会改变,但在这里我没有得到下一个图像, 请帮帮我


提前感谢您

您已将所有图像放入一个数组中。因此,设置一个计算单击次数的变量。每当您单击按钮时,只需将var计数增加1,并将该数组索引图像设置到imageview中……

我认为您必须编写以下代码才能更改图像

-(IBAction)btnNextTapped
{

    self.currentPhotoIndex++;
    if([allPhotosArray  count]>0) {
        if(self.currentPhotoIndex>=[allPhotosArray  count]) {
            self.currentPhotoIndex=0;
        }  

        NSLog(@"====== allphotos in this county :%d",[allPhotosArray  count]);


        mugImage.image = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: [allPhotosDict objectForKey:@"Photo"]]]];

    }
}

为什么不将图像数据存储到数组中,而不是每次点击“下一步”按钮从URL加载图像。什么是allPhotosArray和allPhotosDict以及图片来自URL或本地..?\n是否要在imageView中从给定URL检索图像?是,我正在从Web服务获取图像,通过使用xmlparser,我已将图像放入ArryTank,请您回复,请帮助我
mugImage.image = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: [[allPhotosArray objectAtIndex:self.currentPhotoIndex] valueForKey:@"Photo"]]]];