我將iCarousel集成到我的應用程序中。它工作正常。但我的要求是在單個視圖中顯示兩個按鈕以及這兩個按鈕的特定操作。我將按鈕顯示爲iCarousel應用程序在iOS中的按鈕選擇事件
- (UIView *) carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
UIView *sampleView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 250, 300)];
sampleView.backgroundColor=[UIColor whiteColor];
UIButton* btntrans=[UIButton buttonWithType:UIButtonTypeCustom];
[btntrans setFrame:CGRectMake(45, 40, 105, 50)];
[btntrans setBackgroundColor:[UIColor clearColor]];
btntrans.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:15];
[btntrans setTitle:@"" forState:UIControlStateNormal];
[btntrans setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[sampleView addSubview:btntrans];
UIButton* btntrans1=[UIButton buttonWithType:UIButtonTypeCustom];
[btntrans1 setFrame:CGRectMake(45, 90, 105, 50)];
[btntrans1 setBackgroundColor:[UIColor clearColor]];
btntrans1.titleLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:15];
[btntrans1 setTitle:@"" forState:UIControlStateNormal];
[btntrans1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[sampleView addSubview:btntrans1];
return sampleView;
}
我們可以使用
-(void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index
{
NSLog(@"ITEM SELECTED");
}
爲selection.but如何爲這兩個按鈕在兩個具體行動整體看法?
在此先感謝。
試試這個它爲我工作。 [試試這個](http://stackoverflow.com/questions/22145978/my-custom-button-is-not-getting-click-in-icarousel-ios) – vijay 2016-02-26 15:32:12