0

有人知道如何将 uiscrollviews 对象放入 iCarousel 中吗?我的意思是 IBOutlet 对象。

所以我尝试了这种方式:

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index 
{
UIScrollView *scroll = [UIScrollView alloc] initWithFrame...
scroll.contentSize =..
scroll.backgroundColor = ..
return scroll;
}

它可以工作,但我需要在轮播中放入我用 IBuilder 制作的 uiscrollviews 数组(带有很多按钮)。

我也做了这样的:

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index 
{
UIScrollView *scroll = [scrollArray objectAtIndex:index];
return scroll;
}

但它没有用。

4

1 回答 1

0

这是正确的方法:

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view

    NSString *nibName = [NSString stringWithFormat:@"scroll%i", index + 1];
    NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:nibName owner:self options:nil];
    view = [nibContents objectAtIndex:0];
    return view;
}
于 2012-07-17T14:24:01.680 回答