In my example I am using iCarousel in which I am trying to expand image on clicking on it?
What I have done,after image expands I am adding backButton
on right bottom corner of view
so that I can return to the original view. But that button is not getting click event. Where am I going wrong?
here is my code.
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
UIButton *button = (UIButton *)view;
UIView *buttonBackView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 475, 300)];
[buttonBackView setBackgroundColor:[UIColor blackColor]];
button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0f, 0.0f, 475,300);
UIImage *image=[_rareCSNYArrayImageItems objectAtIndex:index];
[button setBackgroundImage:image forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
[buttonBackView addSubview:button];
return buttonBackView;
}
- (void)buttonTapped:(UIButton *)sender
{
UIButton *button=(UIButton*)sender;
[button setFrame:CGRectMake(0,0,675,400)];
[button.superview setFrame:CGRectMake(-100, -70, 675, 500)];
UIButton *buttonReduce=[[UIButton alloc] initWithFrame:CGRectMake(580, 405, 85, 85)];
[buttonReduce setBackgroundColor:[UIColor clearColor]];
[buttonReduce setBackgroundImage:[UIImage imageNamed:@"reducebuutton.png" ] forState:UIControlStateNormal];
[buttonReduce addTarget:self action:@selector(buttonReduceTapped: ) forControlEvents:UIControlEventTouchUpInside];
[button.superview addSubview:buttonReduce];
[self.view bringSubviewToFront:buttonReduce];
}
- (void)buttonReduceTapped:(UIButton *)sender{
UIButton *button=(UIButton*)sender;
NSLog(@"ButtonClicked");
[button.superview setFrame:CGRectMake(0, 0, 475, 300)];
[button removeFromSuperview];
}