title: Moving uiimageview created programmatically
body: <p>I wrote the following code and it does not work. Picture appears but I can not move it</p>
  
  <pre><code>UIImageView *oneselement = [[UIImageView alloc] initWithFrame:self.view.frame];
  oneselement = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"1el.png"]];
  oneselement.frame = CGRectMake(0, 0, 122, 122);
  [self.view addSubview:oneselement];
  
  
  -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  {
      UITouch *touch = [[event allTouches] anyObject];
  
      if([touch view]==oneselement)
      {
          CGPoint location = [touch locationInView:self.view];
          oneselement.center=location;
      }}
  </code></pre>
  
  <p>I added a picture to view and wrote the following code</p>
  
  <p>.h</p>
  
  <pre><code>@interface ViewController : UIViewController
  {
      IBOutlet UIImageView *oneEl;
  }
  @property (nonatomic,retain) IBOutlet UIImageView *oneEl;
  </code></pre>
  
  <p>.m</p>
  
  <pre><code>-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  {
  UITouch *touch = [[event allTouches] anyObject];
      if([touch view]==oneEl)
      {
          CGPoint location = [touch locationInView:self.view];
          oneEl.center=location;
      }
  }
  </code></pre>
  
  <p>And it works!
  How can I make so that programmatically created by uiimageview could move?</p>
  
  <p><strong>NSMUTABLEARRAY</strong></p>
  
  <pre><code>self.elements=[myElements getElements];
  
  imagesElements = [[NSMutableArray alloc]init];
  for(ElemetsList *item in self.elements)
  {
          UIImageView *oneelement = [[UIImageView alloc] initWithImage:[UIImage imageNamed:item.imgElement]];
          oneelement.frame = CGRectMake(item.positionX, item.positionY, item.width, item.height);
          oneelement.userInteractionEnabled=YES;
          [imagesElements addObject:oneelement];
  }
  
  for(UIImageView *img in imagesElements) 
      [self.view addSubview:img];
  
  -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
  {
      UITouch *touch = [[event allTouches] anyObject];
  
      for(UIImageView *img in imagesElements) 
      {  
          if([self view] == img)
          {
              CGPoint location = [touch locationInView:self.view];
              img.center=location;
          }
      }
  }
  </code></pre>