Hi guys
I got a problem. I would add the same UIImageView at different places to my View. So I could make 10 UIImageViews with the same image but with other names. But i got ca. 50 UIImageViews...
I make my UIImageView with this code:
Code:
CGRect dragRect = CGRectMake(0.0f, 0.0f, 70.0, 70.0);
dragRect.origin = CGPointMake(10, 300);
UIImageView *image = [[UIImageView alloc] initWithFrame:dragRect];
[image setImage:[UIImage imageNamed:@"Apple.png"]];
[self.view addSubview:image;
Now i would like change my dracRect.origin point and make a new UIImageView with another name. I would do this with "for"
Is this possible?
Code:
int x;
for (x=0; x>=3; x=x+1) {
CGRect dragRect = CGRectMake(0.0f, 0.0f, 70.0, 70.0);
dragRect.origin = CGPointMake(x*10, 300); //x koordinate wird immer 10 grösser
NSString *string1 = [[string1 alloc] initWithFormat:@"image%d",x]; //image1, image2, image3
UIImageView *string1 = [[UIImageView alloc] initWithFrame:dragRect];
[string1 setImage:[UIImage imageNamed:@"Apple.png"]];
[self.view addSubview:string1;
}
Thank you a lot for your help!
Franhu