我正在使用 iCarousel 来展示图片。但我想在iCarousel中添加一个按钮。我实现了它,但问题是自定义按钮操作不起作用,当我点击按钮时只有didSelectItem
工作。这是我的代码。拜托,任何人帮助我。
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{
NSString *str=[[appController
sharedappController].allLibraryImagesArrM objectAtIndex:index];
view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)];
((UIImageView *)view).image = [[appController sharedappController].allLibraryImagesArrM objectAtIndex:index];
view.contentMode = UIViewContentModeScaleAspectFit;
//[view addSubview:cross];
UIButton *cross = [[UIButton alloc]init];
cross.frame = CGRectMake(view.frame.size.width/2+30, view.frame.origin.y+30, 40, 40);
[cross setBackgroundImage:[UIImage imageNamed:@"circle"] forState:UIControlStateNormal];
[cross addTarget:self action:@selector(crossMethod) forControlEvents:UIControlEventTouchUpInside];
UIImage *buttonImage = [UIImage imageNamed:@"cross.png"];
[cross setBackgroundImage:buttonImage forState:UIControlStateNormal];
[view addSubview:cross];
return view;
}
答案 0 :(得分:0)
您是否启用了UserInteraction?
启用UserInteraction
[view setUserInteractionEnabled:YES];