0

I want to add/delete images in a view using a UIStepper. So every time you press the '+' the same image is copied within the same viewController, still being able to move/rotate every copy.

I have something like this:

- (IBAction)ValueChanged:(UIStepper *)value
{
    NSMutableArray *imageArray = [[NSMutableArray alloc] init];

    int j = (int) value.value;

    for( int i = 0 ; i < j ; ++i )
    {
        UIImageView *newImageView = [[UIImageView alloc] init];
        newImageView.image = self.myImageView.image;
        [imageArray addObject:newImageView];
        [self.view addSubview:imageArray[i]];
    }
}

but this does not work because it just replaces the previous image.

Is there a proper way to copy the same image multiple times using the UIStepper?

Daniel Larsson
  • 6,278
  • 5
  • 44
  • 82
user3156776
  • 21
  • 1
  • 6
  • 2
    Specify the frame, it is not replacing, new image view hides the previous one. – Midhun MP Jan 03 '14 at 10:57
  • So far so good, the images are added properly but when adding the images don't stay on their current position when touching the '+'. And I'm only able to move one image around with the pan gesture. – user3156776 Jan 03 '14 at 12:09
  • Are you sure the frame have the correct origin? They could be overlapping if the all are located in (0,0) – karlofk Jan 03 '14 at 12:59

0 Answers0