以编程方式将Carousel添加为SubView

时间:2017-03-30 22:12:36

标签: ios objective-c carousel

我正在尝试在View上添加Carousel,如下所示。当我测试它时,没有任何反应,它甚至没有击中任何轮播委托方法。

ViewController.h

@property (nonatomic, strong) iCarousel *carousel;

ViewController.m

carousel = [[iCarousel alloc] initWithFrame:CGRectMake(25, 50, self.view.frame.size.width-50, self.view.frame.size.height-75)];
[self.view addSubview:carousel];

carousel.delegate = self;
carousel.dataSource = self;

self.carousel.type = iCarouselTypeCoverFlow2;

self.items = [NSMutableArray array];
for (int i = 0; i < 100; i++)
{
    [carouselItems addObject:@(i)];
}
[carousel reloadData];

1 个答案:

答案 0 :(得分:-1)

用此

替换您的代码
self.carousel = [[iCarousel alloc] initWithFrame:CGRectMake(25, 50, self.view.frame.size.width-50, self.view.frame.size.height-75)];
self.carousel.delegate = self;
self.carousel.dataSource = self;
self.carousel.type = iCarouselTypeCoverFlow2;
[self.view addSubview:self.carousel];

self.items = [NSMutableArray array];
for (int i = 0; i < 100; i++)
{
    [carouselItems addObject:@(i)];
}
[self.carousel reloadData];