The user can create a unlimited number of UIImageViews with a button press with this code:
- (IBAction) addPicture:(id)sender {
imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0, 45.0, 324, 52.0)];
imageView.tag = a;
imageView.image = [UIImage imageNamed:@"Picture.png"];
a = a + 1;
[self.view addSubview:imageView];
[imageView release];
}
So the first UIImageView gets the tag 1 and the second 2 and so on… Now how can I find out, which UIImageView was select by the user with a touch? I think, I have to do this in touchesBegan, but as I said, I don´t know how to get the right UIImageView.
For example in my app-idea the user can create images with a button and then he select a picture with a touch and can move it and resize it.
Thanks for your help.
Instead of using tag of UIImageView, why don’t you create your own subclass of UIImageView?
You can overwrite touchesBegan method in the subclass, so you can detect a touch.
Then in the subclass, you can move or resize a picture which the subclass has.