Ios 如何在下面的代码中插入图像数组?

Ios 如何在下面的代码中插入图像数组?,ios,arrays,image,gallery,Ios,Arrays,Image,Gallery,我已经下载了一个图库示例代码,但我不知道如何使用它?它显示12张相同的图片,我想要不同的图片,我想要一张图片,而不是一张图片,我该怎么办 下面是我的代码 #import "ViewController.h" #import "UIViewAnimationExplose.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLo

我已经下载了一个图库示例代码,但我不知道如何使用它?它显示12张相同的图片,我想要不同的图片,我想要一张图片,而不是一张图片,我该怎么办

下面是我的代码

#import "ViewController.h"
#import "UIViewAnimationExplose.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.allViews = [[NSMutableArray alloc]init];

    int numberColumn = 0;
    int numberRaw = 0;

    for (int i = 0; i < 12; i++) {

        UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(10 + numberColumn * 252, 10 + numberRaw * 248, 242, 238)];
        img.contentMode = UIViewContentModeScaleAspectFill;
        img.clipsToBounds = YES;
        img.userInteractionEnabled = YES;
        img.image = [UIImage imageNamed:@"becomeapanda_tumblr_com"];
        [self.view addSubview:img];

        [self.allViews addObject:img];

        numberColumn++;
        if (numberColumn > 2) {
            numberRaw++;
            numberColumn =0;
        }
    }

    self.exploseContainer = [[AnimationExploseContainer alloc] initWithViews:self.allViews];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end
#导入“ViewController.h”
#导入“UIViewAnimationExplose.h”
@界面视图控制器()
@结束
@实现视图控制器
-(无效)viewDidLoad
{
[超级视图下载];
//加载视图后,通常从nib执行任何其他设置。
self.allViews=[[NSMutableArray alloc]init];
int numberColumn=0;
int numberRaw=0;
对于(int i=0;i<12;i++){
UIImageView*img=[[UIImageView alloc]initWithFrame:CGRectMake(10+数字列*252,10+数字列*248,242,238)];
img.contentMode=UIViewContentModeScaleAspectFill;
img.clipstobunds=是;
img.userInteractionEnabled=是;
img.image=[UIImage ImageName:@“Becomapanda_tumblr_com”];
[self.view addSubview:img];
[self.allViews addObject:img];
numberColumn++;
如果(数字列>2){
numberRaw++;
numberColumn=0;
}
}
self.exploseContainer=[[AnimationExploseContainer alloc]initWithViews:self.allViews];
}
-(无效)未收到记忆警告
{
[超级记忆警告];
//处置所有可以重新创建的资源。
}
@结束

重命名图像,如img1、img2。。。。。然后像这样修改代码

    for (int i = 0; i < 12; i++) {

    UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(10 + numberColumn * 252, 10 + numberRaw * 248, 242, 238)];
    img.contentMode = UIViewContentModeScaleAspectFill;
    img.clipsToBounds = YES;
    img.userInteractionEnabled = YES;
    img.image = [UIImage imageNamed:[NSString stringWithFormat:@"img%d",i]];
    [self.view addSubview:img];

    [self.allViews addObject:img];

    numberColumn++;
    if (numberColumn > 2) {
        numberRaw++;
        numberColumn =0;
    }
}
for(int i=0;i<12;i++){
UIImageView*img=[[UIImageView alloc]initWithFrame:CGRectMake(10+数字列*252,10+数字列*248,242,238)];
img.contentMode=UIViewContentModeScaleAspectFill;
img.clipstobunds=是;
img.userInteractionEnabled=是;
img.image=[UIImage ImageName:[NSString stringWithFormat:@“img%d”,i]];
[self.view addSubview:img];
[self.allViews addObject:img];
numberColumn++;
如果(数字列>2){
numberRaw++;
numberColumn=0;
}
}

重命名图像,如img1、img2。。。。。然后像这样修改代码

    for (int i = 0; i < 12; i++) {

    UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(10 + numberColumn * 252, 10 + numberRaw * 248, 242, 238)];
    img.contentMode = UIViewContentModeScaleAspectFill;
    img.clipsToBounds = YES;
    img.userInteractionEnabled = YES;
    img.image = [UIImage imageNamed:[NSString stringWithFormat:@"img%d",i]];
    [self.view addSubview:img];

    [self.allViews addObject:img];

    numberColumn++;
    if (numberColumn > 2) {
        numberRaw++;
        numberColumn =0;
    }
}
for(int i=0;i<12;i++){
UIImageView*img=[[UIImageView alloc]initWithFrame:CGRectMake(10+数字列*252,10+数字列*248,242,238)];
img.contentMode=UIViewContentModeScaleAspectFill;
img.clipstobunds=是;
img.userInteractionEnabled=是;
img.image=[UIImage ImageName:[NSString stringWithFormat:@“img%d”,i]];
[self.view addSubview:img];
[self.allViews addObject:img];
numberColumn++;
如果(数字列>2){
numberRaw++;
numberColumn=0;
}
}

重命名图像,如img1、img2。。。。。然后像这样修改代码

    for (int i = 0; i < 12; i++) {

    UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(10 + numberColumn * 252, 10 + numberRaw * 248, 242, 238)];
    img.contentMode = UIViewContentModeScaleAspectFill;
    img.clipsToBounds = YES;
    img.userInteractionEnabled = YES;
    img.image = [UIImage imageNamed:[NSString stringWithFormat:@"img%d",i]];
    [self.view addSubview:img];

    [self.allViews addObject:img];

    numberColumn++;
    if (numberColumn > 2) {
        numberRaw++;
        numberColumn =0;
    }
}
for(int i=0;i<12;i++){
UIImageView*img=[[UIImageView alloc]initWithFrame:CGRectMake(10+数字列*252,10+数字列*248,242,238)];
img.contentMode=UIViewContentModeScaleAspectFill;
img.clipstobunds=是;
img.userInteractionEnabled=是;
img.image=[UIImage ImageName:[NSString stringWithFormat:@“img%d”,i]];
[self.view addSubview:img];
[self.allViews addObject:img];
numberColumn++;
如果(数字列>2){
numberRaw++;
numberColumn=0;
}
}

重命名图像,如img1、img2。。。。。然后像这样修改代码

    for (int i = 0; i < 12; i++) {

    UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(10 + numberColumn * 252, 10 + numberRaw * 248, 242, 238)];
    img.contentMode = UIViewContentModeScaleAspectFill;
    img.clipsToBounds = YES;
    img.userInteractionEnabled = YES;
    img.image = [UIImage imageNamed:[NSString stringWithFormat:@"img%d",i]];
    [self.view addSubview:img];

    [self.allViews addObject:img];

    numberColumn++;
    if (numberColumn > 2) {
        numberRaw++;
        numberColumn =0;
    }
}
for(int i=0;i<12;i++){
UIImageView*img=[[UIImageView alloc]initWithFrame:CGRectMake(10+数字列*252,10+数字列*248,242,238)];
img.contentMode=UIViewContentModeScaleAspectFill;
img.clipstobunds=是;
img.userInteractionEnabled=是;
img.image=[UIImage ImageName:[NSString stringWithFormat:@“img%d”,i]];
[self.view addSubview:img];
[self.allViews addObject:img];
numberColumn++;
如果(数字列>2){
numberRaw++;
numberColumn=0;
}
}

解决方案取决于您要从何处加载图像。最简单的方法是添加到项目中并显示这些图像。在这种情况下:

1) 您必须将图像添加到项目中(文件/将文件添加到..)

2) 创建一个图像名称数组,不少于12个

NSArray *my_image_names = @[@"image1.png", @"image2.png", @"image3.png",....<12 times>..];

解决方案取决于要从何处加载图像。最简单的方法是添加到项目中并显示这些图像。在这种情况下:

1) 您必须将图像添加到项目中(文件/将文件添加到..)

2) 创建一个图像名称数组,不少于12个

NSArray *my_image_names = @[@"image1.png", @"image2.png", @"image3.png",....<12 times>..];

解决方案取决于要从何处加载图像。最简单的方法是添加到项目中并显示这些图像。在这种情况下:

1) 您必须将图像添加到项目中(文件/将文件添加到..)

2) 创建一个图像名称数组,不少于12个

NSArray *my_image_names = @[@"image1.png", @"image2.png", @"image3.png",....<12 times>..];

解决方案取决于要从何处加载图像。最简单的方法是添加到项目中并显示这些图像。在这种情况下:

1) 您必须将图像添加到项目中(文件/将文件添加到..)

2) 创建一个图像名称数组,不少于12个

NSArray *my_image_names = @[@"image1.png", @"image2.png", @"image3.png",....<12 times>..];

哇!哇!哇!真的很有效,非常感谢!你好,我现在有另一个问题,你能帮我吗?告诉我该怎么办。在“Demo2ViewController.m”中,我不想要任何故事板或XIB,因为我需要将其添加到我的表视图单元格中。请帮助我。非常感谢哇!哇!哇!真的很有效,非常感谢!你好,我现在有另一个问题,你能帮我吗?告诉我该怎么办。在“Demo2ViewController.m”中,我不想要任何故事板或XIB,因为我需要将其添加到我的表视图单元格中。请帮助我。非常感谢哇!哇!哇!真的很有效,非常感谢!你好,我现在有另一个问题,你能帮我吗?告诉我该怎么办。在'Demo2ViewController.m'中,我不想要任何故事板或XIB,因为我需要将其添加到我的表视图cell.pl中