私はiCarouselのこのメソッドを次のように実装しました。
最初は固まっていて、数秒後にはスクロールできるようになります。また、スクロール中に画像が重ならないようにしたいので、すべての画像が各アイテム間で等距離になるようにします。
このコードの何が問題になっていますか?または私は何かが欠けていますか?
-(void)addiCarousel
{
carousel.frame = CGRectMake(324, 50, 375, 195);
[self.view addSubview:carousel];
self.items = [[NSMutableArray alloc] initWithObjects:@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg",@"5.jpg", nil];
carousel.type = iCarouselTypeCoverFlow2;
[carousel reloadData];
}
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return [items count];
}
- (BOOL)carouselShouldWrap:(iCarousel *)carousel
{
return NO;
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
// if (view == nil)
// {
view = [[[UIImageView alloc] initWithFrame:CGRectMake(649, 50, 375 , 195)] autorelease];
view.contentMode = UIViewContentModeCenter;
view.layer.borderWidth = 8.0f;
view.layer.borderColor = [[UIColor blackColor] CGColor];
view.contentMode = UIViewContentModeScaleToFill;
// }
((UIImageView *)view).image = [UIImage imageNamed:[self.items objectAtIndex:index]];
NSLog(@"index : %d",index);
NSLog(@"%@",[self.items objectAtIndex:index]);
return view;
}