My Scenario is, i have collection of images in an array. dynamically creating UIImageView in a UIScrollView. code is shown below.
- (void)createImage
{
UIImageView *imgFashion;
CGFloat newHeight = 0.0;
int xPos = 10;
int yPosL = 10;
int yPosR = 10;
btnScroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 83, 320, 485)];
for (int i=0; i<[buttonImageArr count];i++)
{
UIImage *img = [buttonImageArr objectAtIndex:i];
originalImageWidth = img.size.width;
originalImageHeight = img.size.height;
newHeight = originalImageHeight * (150/originalImageWidth);
if (xPos == 10)
{
imgFashion=[[UIImageView alloc]initWithFrame:CGRectMake(xPos, yPosL, 150, newHeight)];
xPos = 160;
yPosL = yPosL + newHeight;
}
else
{
imgFashion=[[UIImageView alloc]initWithFrame:CGRectMake(xPos, yPosR, 150, newHeight)];
imgFashion.tag=i;
xPos = 10;
yPosR +=newHeight;
}
imgFashion.tag=i;
imgFashion.image = [buttonImageArr objectAtIndex:i];
imgFashion.userInteractionEnabled = YES;
[btnScroller addSubview:imgFashion];
imgFashion.layer.borderWidth = 3.0;
imgFashion.layer.borderColor = [UIColor whiteColor].CGColor;
UISwipeGestureRecognizer *profile_SwipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipes_profile:)];
profile_SwipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
profile_SwipeGestureRecognizer.numberOfTouchesRequired = 1;
profile_SwipeGestureRecognizer.enabled = YES;
[imgFashion addGestureRecognizer:profile_SwipeGestureRecognizer];
btnScroller.scrollEnabled=YES;
}
btnScroller.contentSize=CGSizeMake(xPos, yPosR+newHeight);
[self.view addSubview:btnScroller];
}
Now i will swipe top of any images, i want to remove that image from view. i write the code for this functionality.
- (void)handleSwipes_profile:(UISwipeGestureRecognizer *)paramSender
{
if (paramSender.direction == UISwipeGestureRecognizerDirectionLeft)
{
[paramSender.view removeFromSuperview];
selectedBtn = paramSender.view.tag;
[buttonImageArr removeObjectAtIndex:selectedBtn];
[btnScroller removeFromSuperview];
btnScroller = nil;
[self createImage];
[self.view setNeedsDisplay];
}
}
My Question is, i want to rotate the image before remove from view.