title: Deleting Images from Imageview In IOS
body: <p>I have array of images; in scrollview when I press button delete button will place on the top of image view when press the cross button the imageview not get removed or fade out. How can I resolve these issues?</p>
  <p>Here is my code</p>
  <pre><code>   -(void)getimagefunction
      {
          BusinessUser *busUser = [BusinessUser getBusinessUser];
          NSLog(@&quot;%@&quot;, _GalleryimageDictionary);
          _GalleryimageArry =[[NSMutableArray alloc]init];
          NSMutableArray *resultarray =[_GalleryimageDictionary valueForKey:@&quot;images&quot;];
          if ([resultarray count] != 0) {
              NSString*baseurl =[NSString stringWithFormat:@&quot;%@%@&quot;,BaseUrl,@&quot;uploads/BusinessImages/&quot;];
              NSString *businessid = [NSString stringWithFormat:@&quot;%lld&quot;,busUser.business_id];
              NSString*checkstring =[NSString stringWithFormat:@&quot;%@%@&quot;,baseurl,businessid];
              for(int i=0; i&lt;resultarray.count;i++){
                  _finalString =[NSString stringWithFormat:@&quot;%@/%@&quot;,checkstring,[resultarray objectAtIndex:i]];
                  NSURL * imageURL = [NSURL URLWithString:[_finalString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                  NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation([UIImage imageWithData:[NSData dataWithContentsOfURL:imageURL]])];
                  UIImage *image = [UIImage imageWithData:imageData];
                  
                  [_GalleryimageArry addObject:image];
              }
              
              for(int i=0; i&lt;_GalleryimageArry.count;i++){
                  _imageV = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.view.frame) * i/2*0.7, 0, 100, 100)];
                  
                  self.Crossbtn =[[UIButton alloc]initWithFrame:CGRectMake(_imageV.image.size.width/2+80,0,20,20)];
                  UIImage *btnImage = [UIImage imageNamed:@&quot;CrossImageICon&quot;];
                  [self.Crossbtn setImage:btnImage forState:UIControlStateNormal];
                  _imageV.contentMode = UIViewContentModeScaleAspectFill;
                _imageV.image = [_GalleryimageArry objectAtIndex:i];
                  [_imageV setUserInteractionEnabled:YES];
                  _imageV.tag = i;
                  self.Crossbtn.tag =i;
                  [self.Crossbtn addTarget:self action:@selector(deleteImage:) forControlEvents:UIControlEventTouchUpInside];
                  UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapMethod:)];
                  [_imageV addGestureRecognizer:tap];
                  [self.imageV addSubview:self.Crossbtn];
                  if ([_crossstringshow isEqualToString:@&quot;1&quot;]) {
                        self.Crossbtn.hidden =NO;
                  }
                else
                {
                      self.Crossbtn.hidden =YES;
                }
                  [self.imageGalleryscroll addSubview:_imageV];
                  [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
              }
              self.imageGalleryscroll.delegate = self;
              index=0;
              
              
              
              self.imageGalleryscroll.contentSize = CGSizeMake(CGRectGetWidth(self.view.frame) * _GalleryimageArry.count/2*0.7, CGRectGetHeight(self.imageGalleryscroll.frame));
              
              [self.imageGalleryscroll setPagingEnabled:YES];
              
              [self.imageGalleryscroll setShowsHorizontalScrollIndicator:NO];
              self.imageGalleryscroll.alwaysBounceVertical = NO;
              
          }
          
          else
          {  [MBProgressHUD hideAllHUDsForView:self.view animated:YES];
              //  self.business_galleryimg.hidden=NO;
              self.imageGalleryscroll.hidden =YES;
              
          }
          
      }
      
      -(void)deleteImage:(UIButton *)sender
      {id superv = [sender superview];
          [superv removeFromSuperview];
          
      
      [self.GalleryimageArry removeObjectAtIndex:index];
      }
  </code></pre>