我正在尝试使用 iCarousel 库在我的应用程序中实现轮播类型选择器,但是当我加载应该显示轮播的视图时,什么都没有出现。
以下是相关代码:
iCarousel 委托方法:
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel {
return 65;
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view {
// Create a number label representing a numeric WPM option
UILabel *numberLabel = nil;
// Create new view if no view is available for recycling
if (!view) {
view = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 220, 60)];
numberLabel = [[UILabel alloc] initWithFrame:view.bounds];
numberLabel.backgroundColor = [UIColor clearColor];
numberLabel.textColor = [UIColor whiteColor];
numberLabel.textAlignment = NSTextAlignmentCenter;
numberLabel.tag = 1;
[view addSubview:numberLabel];
}
else {
numberLabel = (UILabel *)[view viewWithTag:1];
}
// Calculate the number's value depending on the index value being retrieved
int number = 200 + (index * 20);
numberLabel.text = [@(number) stringValue];
return view;
}
并在viewDidLoad:
:
self.carousel = [[iCarousel alloc] initWithFrame:CGRectMake(120, 35, 150, 50)];
self.carousel.type = iCarouselTypeLinear;
[self.view addSubview:self.carousel];
我到底错过了什么把事情搞砸了?