내 예제에서 나는 클릭하여 이미지를 확장하려고하는데 iCarousel을 사용하고 있습니까? 이미지를 확장 한 후 을 오른쪽 하단 모서리에 view
에 추가하여 원본보기로 되돌릴 수 있습니다. 하지만 그 버튼은 클릭 이벤트를 얻지 못합니다. 내가 어디로 잘못 가고 있니?내 맞춤 검색 버튼이 iCarousel iOS에서 클릭을 얻지 못합니까?
여기 내 코드입니다.
- (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];
}
버튼의 수퍼 뷰에서 userInteraction이 활성화되어 있는지 확인합니다. – croyneaus4u
@ croyneaus4u 여전히 작동하지 않습니다. –