我想滾動輪播視圖中的所有圖像。但在我看來,當我滾動中間圖像時,動畫開始移動。如果我觸摸旁邊的其他圖像,它們不會移動。我在viewForItemAtIndex方法中使用按鈕。你有什麼想法如何移動所有可見的圖像?如何滾動icarousel中的所有圖像
這是我viewForItemAtIndexMethod:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(ReflectionView *)view
{
UIButton* button = nil;
if (view == nil)
{
UIImage *image = [arrKitapKapaklari objectAtIndex:index];
view = [[[ReflectionView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, image.size.width, image.size.height)] autorelease];
//no button available to recycle, so create new one
[view setBackgroundColor:[UIColor clearColor]];
button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0f, 0.0f, image.size.width, image.size.height);
[button setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
[button setBackgroundImage:image forState:UIControlStateNormal];
button.titleLabel.font = [button.titleLabel.font fontWithSize:50];
[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
button.tag = 99;
[view update];
[view addSubview:button];
}
else
{
button = (UIButton *)[view viewWithTag:99];
}
[button setTitle:[NSString stringWithFormat:@"%i", index] forState:UIControlStateNormal];
return view;
}
什麼是您的iCarousel框架?您是通過IB還是通過代碼初始化它? – 2012-03-12 12:58:08
我在代碼中初始化。但我認爲這是關於carcarl的委託方法。我嘗試解決,但我是新手。我不明白所有的方法 – 2012-03-12 13:00:51
正如我記得iCarousel有一個平移手勢識別器,它在整個視圖上工作。你可以發佈你的代碼片段,你設置旋轉木馬? – 2012-03-12 13:02:54